随笔分类 - 数据结构—RMQ
摘要:题目:http://poj.org/problem?id=3368题意:给定n个数,顺序为非下降,询问某个区间内的数出现最多的数的 出现次数。。大白书上的 例题。。算是RMQ变形了,对 原数组重新分段,并标记相同的个数为 该段的数值,然后RMQ... 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 100005; 8 const int maxm = 30; 9 10 int d_max[maxn][maxm],a[maxn];11 int...
阅读全文
摘要:RMQ支持操作:Query(L, R): 计算Min{a[L],a[L+1], a[R]}。预处理时间是O(nlogn), 查询只需 O(1)。RMQ问题 用于求给定区间内的最大值/最小值问题。。询问的次数多的时候 好用。。这个题目我至少得开数组开到 80000才能过,不知道为什么。。刚开始还写错了,贡献了好多RE和WA..题目:http://poj.org/problem?id=3264题意:给n个数,q次询问,求最值的差。。 1 #include 2 #include 3 using namespace std; 4 const int maxn = 80000; 5 const in..
阅读全文

浙公网安备 33010602011771号