
主席树
文章平均质量分 91
Hallelujah520
这个作者很懒,什么都没留下…
展开
-
Spoj 10628. Count on a tree 树上主席树
给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权。其中lastans是上一个询问的答案,初始为0,即第一个询问的u是明文。Input 第一行两个整数N,M。 第二行有N个整数,其中第i个整数表示点i的权值。 后面N-1行每行两个整数(x,y),表示点x到点y有一条边。 最后M行每行两个整数(u,v,k),表示原创 2017-07-23 00:50:34 · 388 阅读 · 0 评论 -
zoj 2112 树状数组 套主席树 动态求区间 第k个数
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 m原创 2017-07-23 00:44:57 · 401 阅读 · 0 评论 -
hdu 5919 主席树保留区间数的种类数目
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 subsequ原创 2017-07-21 19:51:58 · 376 阅读 · 0 评论 -
poj 2104 主席树 板子
// 题意// 给出一个序列,m组查询,对每个查询(i, j, k)需要输出区间[i, j]中第k大的数。// 题解// 主席树的入门题。 // 主席树其实就是可持久化线段树,比如现有n组操作,每组操作可更改序列中a[i]的值,并且需要支持序列求和,当然这个问题通过线段树很好解决。比如某种询问,需要你退回到第k步操作以后,这就需要可持久化线段树去解决。 // 事实上上述问题也有一种离线的做法原创 2017-07-21 13:54:02 · 502 阅读 · 0 评论