poj 3368 Frequent values -Sparse-Table】的更多相关文章

传送门:http://poj.org/problem?id=3368 Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 23016   Accepted: 8060 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that,…
/************************************************************ 题目: Frequent values(poj 3368) 链接: http://poj.org/problem?id=3368 题意: 给出n个数和Q个询问(l,r),对于每个询问求出(l,r)之 间连续出现次数最多的次数 算法: RMQ 思路: 借助数组f[i].表示第i位前面有f[i]个相同的数.对于 每个区间(l,r).暴力求前面几个相同的数.然后在用RMQ 求后面…
Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14742   Accepted: 5354 Description You are given a sequence of n integersa1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consi…
Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13516   Accepted: 4971 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries cons…
                                                     Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15229   Accepted: 5550 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16537   Accepted: 5981 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indice…
题目链接:http://poj.org/problem? id=3368 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, dete…
题目:http://poj.org/problem?id=3368 题意:给定n个数,顺序为非下降,询问某个区间内的数出现最多的数的 出现次数.. 大白书上的 例题..算是RMQ变形了, 对 原数组重新分段,并标记相同的个数为 该段的数值,然后RMQ... #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm>…
Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, determine the most frequent value among t…
[题目链接] http://poj.org/problem?id=3368 [题目大意] 有一个有序序列,要求区间查询出现次数最多的数 [题解] 维护每个区间左端点和右端点,以及左右的长度,还有区间的答案 每次线段合并的时候,对区间数据进行合并即可. [代码] #include <cstdio> #include <algorithm> using namespace std; const int N=100010; struct data{int a,b,l,r,val;}T[N…