zoj2112】的更多相关文章

题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2112 经典的动态区间第K大. 用树状数组套线段树. 对原数组建一个树状数组,每个树状数组的结点代表一个线段树,这个线段树以权值为下标,包括这个树状数组的结点包含的区间. 插入的时候可以由树状数组和线段树写法类比,只与logn棵线段树有关,每棵线段树用时logn,总共的时间复杂度n*logn^2. 询问[l,r]的时候,类似与前缀和,找到与l-1有关的logn棵线段树…
Dynamic Rankings Time Limit: 10000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Status Description The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the…
bzoj1901&zoj2112&cogs257 Dynamic Rankings(动态排名系统) cogs zoj bzoj-权限 题解 bzoj和zoj都是骗访问量的233,我没有权限 带修改区间k小值,看了学习了题解一次AC真开心... 不带修改的是前缀和套主席树,\(O(log_2n)\)查询,要修改只能\(O(nlog_2n)\)乱搞. 把外层前缀和改成树状数组,即第\(i\)个主席树从存\(1\) ~ \(i\)的值域改成存\(i-lowbit(i)+1\) ~ \(i\)的值…
今天学习了一个奇技淫巧--整体二分.关于整体二分的一些理论性的东西,可以参见XRH的<浅谈数据结构题的几个非经典解法>.然后下面是一些个人的心得体会吧,写下来希望加深一下自己的理解,或者如果有人看了或许也有些帮助. ZOJ2112是一道典型的带修改的区间第k大的问题,有一些树套树等的数据结构可以在线处理这样的问题.但是当题目并不要求在线处理的时候,其实我们可以选择一下整体二分的思想. 个人对整体二分的理解是这样子的,首先对于修改,即把a[xi]=yi(1<=yi<=C)的时候,我们…
Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They…
BZOJ1901: 线段树套线段树做法: (外层线段树 里层动态开节点的权值线段树) 有一个小小的trick 可以省掉二分变成nlog^2n的 就是把查询的区间都取出来- logn个一起走- 2016.2.14Upd //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=10050; int root[N*8],n…
Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They…
题意:n个数,q个询问 (n<=50000, q<=10000) Q x y z 代表询问[x, y]区间里的第z小的数 C x y    代表将(从左往右数)第x个数变成y 上篇介绍了在[x, y]区间内查询第z小的数的方法(静态主席树) 本题有更新操作 若仍用上篇的做法, 每次更新一个数,需要更新的是T[i], T[i+1]... ...T[n](该数所在的树以及它后面的所有树) 因为每棵树T[i]所记录的都是前缀(1到i的数出现的次数) 因此,改变i,会影响i到n的所有树 这样,每次更新…
有了上一题的经验(POJ的静态区间第K最值)再解决这道题就轻松多了 空间5256KB,时间3330ms,如果把动态开点的平衡树换成数组模拟的话应该会更快 之所以选择了平方分割而不是树套树,不仅是所谓趁热打铁,更是因为: 平方分割的修改操作,无论编程复杂度还是时间复杂度都远优于树套树. 代码如下:(鄙人不才,不会压代码,所以写了300多行Σ( ° △ °|||) template <class T> struct SbtNode { typedef SbtNode<T> Node;…
The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They have developed a more powerful system such that for N numbers a[1],…