
主席树
csu_xiji
这个作者很懒,什么都没留下…
展开
-
主席树
参考博客:https://blog.youkuaiyun.com/pengwill97/article/details/80920143说一下对静态查询区间第k大操作的理解:首先把原序列去重,做离散化操作。初始化工作:按照顺序分别在树中插入原序列中的n个元素。查询:查询原序列区间[l,r]内的第k大的数。主席树节点:设该节点管理的区间为[l,r],则该点的值维护的是离散后的序列中>...原创 2019-07-25 12:32:52 · 120 阅读 · 0 评论 -
洛谷 P3919 【模板】可持久化数组(可持久化线段树/平衡树)
https://www.luogu.org/problem/P3919题目背景UPDATE : 最后一个点时间空间已经放大标题即题意有了可持久化数组,便可以实现很多衍生的可持久化功能(例如:可持久化并查集)题目描述如题,你需要维护这样的一个长度为 N N N 的数组,支持如下几种操作在某个历史版本上修改某一个位置上的值访问某个历史版本上的某一位置的值此外,每进行一次操作(对于...原创 2019-08-17 15:33:29 · 136 阅读 · 0 评论 -
codeforces 1000F One Occurrence 主席树
http://codeforces.com/problemset/problem/1000/FYou are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers li and ri. For each query, you have to fi...原创 2019-07-27 12:29:07 · 292 阅读 · 0 评论 -
洛谷P2633 Count on a tree 静态树链第k小(LCA+主席树)
https://www.luogu.org/problem/P2633展开题目描述给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权。其中lastans是上一个询问的答案,初始为0,即第一个询问的u是明文。输入格式第一行两个整数N,M。第二行有N个整数,其中第i个整数表示点i的权值。后面N-1行每行两个...原创 2019-08-04 20:06:20 · 200 阅读 · 0 评论 -
HDU 5919 主席树+思维
http://acm.hdu.edu.cn/showproblem.php?pid=5919Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯,an There are m queries.In the i-th query, you are given two integers li a...原创 2019-07-26 17:23:08 · 187 阅读 · 0 评论 -
ZOJ 2112 动态区间第k大 树状数组套主席树
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2112The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the ...原创 2019-07-26 14:17:49 · 257 阅读 · 0 评论 -
区间动态第k大模板(树状数组套主席树)
原理:https://blog.youkuaiyun.com/g21wcr/article/details/86652152https://blog.youkuaiyun.com/u014664226/article/details/47839973板子一:时空复杂度:O((n+q)*logn*logn)洛谷 P2617#include<bits/stdc++.h>using...原创 2019-07-26 14:12:38 · 277 阅读 · 0 评论 -
BZOJ 1146 网络管理Network 树链剖分+树状数组套主席树
https://www.lydsy.com/JudgeOnline/problem.php?id=1146Description M公司是一个非常庞大的跨国公司,在许多国家都设有它的下属分支机构或部门。为了让分布在世界各地的N个部门之间协同工作,公司搭建了一个连接整个公司的通信网络。该网络的结构由N个路由器和N-1条高速光缆组成。每个部门都有一个专属的路由器,部门局域网内的所有机...原创 2019-08-03 23:53:04 · 189 阅读 · 0 评论 -
洛谷 P2617 Dynamic Rankings 树状数组套主席树(动态区间第k大)
https://www.luogu.org/problem/P2617题目描述给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是多少(1≤k≤j-i+1),并且,你可以改变一些a[i]的值,改变后,程序还能针对改变后的a继续回答上面的问题。你需要编一个这样的程序,从...原创 2019-07-26 11:23:45 · 180 阅读 · 0 评论 -
codeforces 786C Till I Collapse 主席树
http://codeforces.com/problemset/problem/786/CRick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated n Mr. Meeseeks, standing in a line num...原创 2019-07-31 00:11:40 · 457 阅读 · 1 评论 -
HDU 6278 主席树+二分
http://acm.hdu.edu.cn/showproblem.php?pid=6278The h-index of an author is the largest h where he has at least h papers with citations not less than h.Bobo has published n papers with citations a1,a...原创 2019-07-25 18:35:38 · 177 阅读 · 0 评论 -
HDU 4348 可持久化线段树+维护区间和+区间修改
http://acm.hdu.edu.cn/showproblem.php?pid=4348BackgroundTo 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 ...原创 2019-07-25 17:20:17 · 676 阅读 · 0 评论 -
HDU 2665 Kth number 主席树
http://acm.hdu.edu.cn/showproblem.php?pid=2665Give you a sequence and ask you the kth big number of a inteval.InputThe first line is the number of the test cases.For each test case, the first l...原创 2019-07-25 15:19:32 · 154 阅读 · 0 评论 -
HDU 4417 Super Mario 主席树求小于等于x的数的个数
http://acm.hdu.edu.cn/showproblem.php?pid=4417Problem DescriptionMario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in tro...原创 2019-09-01 17:20:18 · 255 阅读 · 0 评论