HDU 3727 Jewel 主席树】的更多相关文章

题意: 一开始有一个空序列,然后有下面四种操作: Insert x在序列尾部加入一个值为\(x\)的元素,而且保证序列中每个元素都互不相同. Query_1 s t k查询区间\([s,t]\)中第\(k\)小的元素. Query_2 x查询元素\(x\)的名次 Query_3 k查询整个区间的第\(k\)小值 分析: 首先离线一下所有查询,然后离散化,剩下的都是很经典的主席树操作. #include <cstdio> #include <cstring> #include <…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=3727 题意: 对一段序列进行四种操作: Insert x :在序列尾部插入一个x: Query_1 s t k : 求区间[s,t]中第k小的数 Query_2 x: 求x在序列中的排名 Query_3 k:求序列中第k小的数 思路; 第2,4个操作明显就是很裸的主席树求第k小.第3个操作我们可以单独用个树状数组维护,第一个操作因为会对序列造成影响,我们可以对所有操作进行离线处理, 分析完后可以发现这…
题目大意 对一个序列进行以下四种操作: 1.Insert x 在序列尾部插入x 2.Query_1 s t k 查询区间[s,t]的第k小 3.Query_2 x 查询x的在序列中排名 4.Query_3 k 查询序列中的第k小 题解 第一个和第二个显然是主席树能够实现的功能,第三四个操作用vector+lower_bound就可以实现,妈蛋,写完交上去一直WA,fuck,然后把存储操作类型的每个字符串的大小从10改成15居然变RE了!!!才发现用来存储操作的数组开小了,只开到100000...…
Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯,ana1,a2,⋯,anThere are m queries. In the i-th query, you are given two integers lili and riri. Consider the subsequence ali,ali+1,ali+2,⋯,ariali,ali+1,ali+2,⋯,ari. We can de…
Background To The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker. The premise of To The Moon is based around a technology that allows us to permanently reconstruct the memory on dying ma…
Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to the boss’s castle as a line (the length is n), on…
题面一看就是裸的数据结构题,而且一看就知道是主席树... 一共四种操作:1:把区间[l, r]的数都加上d,并且更新时间.2:查询当前时间的区间和.3:查询历史时间的区间和.4:时光倒流到某个时间. 正常来说,主席树比较难支持区间操作,但是我们可以用标记永久化的方法去实现区间操作.标记永久化和懒标记下放不一样,标记永久化是这样操作的:对所有和标记区间相关的区间,直接加上这次操作的影响,如果这个区间被标记区间完全覆盖,就打上标记.查询的时候,需要把访问沿途的所有的区间的标记算上. 代码: #inc…
大意: 给定串$s$, $q$个询问$(l,r,k)$, 求子串$s[l,r]$的第$k$次出现位置. 本来是个简单签到题, 可惜比赛的时候还没学$SA$...... 好亏啊 相同的子串在$SA$中是一定是连续的一段$[L,R]$ 满足对于$L<i\le R$都有$h_i\ge r-l+1$ 可以先用线段树二分出$L,R$, 然后主席树查询第$k$大即可 #include <iostream> #include <algorithm> #include <cstdio&…
Jewel Problem Description   Jimmy wants to make a special necklace for his girlfriend. He bought many beads with various sizes, and no two beads are with the same size. Jimmy can't remember all the details about the beads, for the necklace is so long…
Super Mario Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5101    Accepted Submission(s): 2339 Problem Description Mario is world-famous plumber. His “burly” figure and amazing jumping abilit…