算法技巧-离散化
文章平均质量分 81
介绍离散化的使用
memcpy0
希望探索文理结合的自由之路。
展开
-
【PAT顶级】1010 Lehmer Code (35 分)【树状数组/离散化】
According to Wikipedia: “In mathematics and in particular in combinatorics, the Lehmer code is a particular way to encode each possible permutation of a sequence of nnn numbers.” To be more specific, for a given permutation of items {A1,A2,…,AnA_1, A_2, \d原创 2021-05-22 19:22:25 · 226 阅读 · 0 评论 -
算法学习笔记(7) 离散化
文章目录一、定义二、举例三、模板代码 一、定义 离散化,似乎很麻烦的样子,其实就是在我们只需要数据的大小关系时,用排名来代替源数据的一种预处理方法。 本质是一种哈希,在保持原序列大小关系(从大到小或相反)的前提下,将源数据映射成正整数。 比如说,当源数据很大、含有负数、小数时,难以表示成数组下标,一些算法或数据结构无法使用,这时我们可以考虑将其离散化。 离散化的一个小坑,就是如何将序列中相同的数映...原创 2020-03-20 12:25:15 · 325 阅读 · 0 评论