题目:单点更新查询区间第k大 按照主席树的思想,要主席树套树状数组.即按照每个节点建立主席树,然后利用树状数组的方法来更新维护前缀和.然而,这样的做法在实际中并不能AC,原因即卡空间. 因此我们采用一种叫做整体二分的方法. 说一下具体做法: 首先要离线处理 我们把原数列也当成单点更新的操作,而更改值我们则看成两个操作,第一个是删掉原来位置的值,第二个是把新的值放置在这个位置,这样一来我们就可以得到最长n*3的操作序列. 然后就是我们的整体二分步骤了,首先我们对答案进行二分,这时我们会获得一个mi…
SP3946 K-th Number (/2和>>1不一样!!) #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <…
在今天三黑(恶意评分刷上去的那种)两紫的智推中,突然出现了P3834 [模板]可持久化线段树 1(主席树)就突然有了不详的预感2333 果然...然后我gg了!被大佬虐了! hdu 2665 Kth number 题意就不写了,太经典了(可我还是不会这题,我太菜了) 大佬的题解写的太神仙了,我这么菜的人都看懂了2333,所以我就不写了... 不过这题是真的坑啊...老师在上面讲的时候,我们开始提交(他们交主席树,我交整体二分)然后等讲完我们还没过23333 MLE.TLE.WA(可能还有CE)轮…
题目大意 给定一个数列,编号从 1 到 n,现在有 m 个操作,操作分两类: 1. 修改数列中某个位置的数的值为 val 2. 询问 [L, R] 这个区间中第 k 大的是多少 n<=50,000   m<=10,000 做法分析 本以为某一天我会用 splay 或者 树套树 去搞的,结果被用块状链表搞了 其实这题和链表没什么关系,利用了块状链表分块操作的思想 首先,看看数据规模:n<=50,000,那么,我们每一块的大小可以设置为 sqrt(n) 大概 230 的样子 用一个数组 A …
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…
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…
以下时空限制来自zoj Time limit 10000 ms Memory limit 32768 kB OS Linux Source Online Contest of Christopher's Adventure Author XIN, Tao 吐槽 zoj卡空间卡得太死了--32MB,远远不够放没优化过的主席树套树状数组--刚开始时段错误,还以为是t数组没开够,还是学得不扎实,别人说是就是,都没自己想想算算--后来二分骗数据,发现在还没开始操作.正在建最初的主席树时空间就爆了.没有优…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2112 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. T…
Dynamic Rankings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2112 Description The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query l…
Dynamic Rankings 带修改的区间第K大其实就是先和静态区间第K大的操作一样.先建立一颗主席树, 然后再在树状数组的每一个节点开线段树(其实也是主席树,共用节点), 每次修改的时候都按照树状数组的方式去修改,并且修改那些地方.查询的时候就是查询原主席树+树状数组的值. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",std…