【HDU 4343】Interval query(倍增)】的更多相关文章

题目链接  2012多校5 Problem D 题意  给定$n$个区间,数字范围在$[0, 10^{9}]$之间,保证左端点严格大于右端点. 然后有$m$个询问,每个询问也为一个区间,数字范围在$[0, 10^{9}]$之间,保证左端点严格大于右端点. 每个询问求的是在当前区间内能得到不相交的给定的区间的数目的最大值. 为了方便我先把给定区间的左端点全部$+1$,询问的区间的左端点也通通$+1$. 然后全部扔到数组里面去离散化一遍,再取出来. 这个时候问题就比较直观了. 其实这个题和  Cod…
最大不相交集合的数量.思路是dp[i][j]表示已经有i个不相交集合下一个不相交集合的最右边界.离散化后,通过贪心解. /* 4343 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector&g…
D - Interval queryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88748#problem/D Description This is a very simple question. There are N intervals in number axis, and M queries just like “QUERY(a,b)…
D - Interval queryTime Limit: 1.5 Sec Memory Limit: 256 MB Description This is a very simple question. There are N intervals in number axis, and M queries just like “QUERY(a,b)” indicate asking the maximum number of the disjoint intervals between (a,…
BUPT2017 wintertraining(15) #8D 题意 给你x轴上的N个线段,M次查询,每次问你[l,r]区间里最多有多少个不相交的线段.(0<N, M<=100000) 限时15000 MS 题解 如果不看限时,当作是1000MS的话= =,那么可以用倍增来做. 先按右端点排序. 可以去掉一下包含了其它区间的区间,可以优化一点点. 用 f[i][j] 表示 i 节点下 \(2^n\) 个不相交的线段下标. 预处理出 f 数组. 查询的时候,左端点用二分,然后右端点用倍增来找.…
题目: Problem Description This is a very simple question. There are N intervals in number axis, and M queries just like “QUERY(a,b)” indicate asking the maximum number of the disjoint intervals between (a,b) . Input There are several test cases. For ea…
Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 976    Accepted Submission(s): 375 Problem Description The shorter, the simpler. With this problem, you should be convinced of this tru…
GCD/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). There are Q(Q≤100,000) queries. For each query l,r you have to calculate gcd(al,,al+1,...,ar) a…
去博客园看该题解 题意 给定n个区间[a,b),都是左闭右开,有m次询问,每次询问你最多可以从n个区间中选出多少[L,R]的子区间,使得他们互不相交. n,m<=10^5. 区间下标<=10^9. 题解 这题要用倍增. 首先,给区间按照左端点编号排个序. 如果区间A包含了区间B,那么A一定没用,扔了. 那么剩余的区间[x,y]的x和y一定都是升序的. 之后,就是对于区间的贪心了: 找到一个区间[xi,yi]之后,一定是寻找一个xj>yi且xj最小的那个区间[xj,yj],所以设该区间的编…
Typesetting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 144    Accepted Submission(s): 72 Problem Description Yellowstar is writing an article that contains N words and 1 picture, and the i-…