题目链接: http://poj.org/problem?id=2104 K-th Number Time Limit: 20000MSMemory Limit: 65536K 问题描述 You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data…
达神主席树讲解传送门:http://blog.csdn.net/dad3zz/article/details/50638026 2016-02-23:真的是模板题诶,主席树模板水过.今天新校网不好,没有评测,但我立下flag这个代码一定能A.我的同学在自习课上考语文,然而机房党都跑到机房来避难了\(^o^)/~ 2016-02-24:果然A乐~~~,我们机房党又躲过啦数学考试.良心不安啊 #include<cstdio> #include<cstring> #include<…
主席树的实质其实还是一颗线段树, 然后每一次修改都通过上一次的线段树,来添加新边,使得每次改变就改变logn个节点,很多节点重复利用,达到节省空间的目的. 1.不带修改的区间第K大. HDU-2665 模板题 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt",&q…
题意: 标记为\(1-n\)的竹子,\(q\)个询问,每次给出\(l,r,x,y\).要求为砍区间\(l,r\)的柱子,要求砍\(y\)次把所有竹子砍完,每次砍的时候选一个高度,把比他高的都砍下来,并且这\(y\)次砍下来长度都相等,问第\(x\)次砍在什么高度. 思路: 显然就是要求选一个高度砍,使得剩下的高度为\((sum[r] - sum[l - 1]) - (sum[r] - sum[l - 1])/y * x\),那么直接建好主席树,然后二分出这个高度. 主席树好啊. 代码: #inc…
Just h-index Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 438    Accepted Submission(s): 203 Problem Description The h-index of an author is the largest h where he has at least h papers wit…
poj 2104 K-th Number 主席树+超级详细解释 传送门:K-th Number 题目大意:给出一段数列,让你求[L,R]区间内第几大的数字! 在这里先介绍一下主席树! 如果想了解什么是主席树,就先要知道线段树,主席树就是n棵线段树,因为线段树只能维护最大值或者最小值,要想求出第二大的数字怎么办呢?两颗线段树呗!好,那么第n大呢,就可以构造n棵线段树,这样的内存是显然会爆掉的,那么怎么办呢?因为每一次更新都是更新的是从叶子节点到根节点的一条路,路的长度大约是logn,如下图红色的为…
K-th Number Time Limit: 20000MS Memory Limit: 65536K Case Time Limit: 2000MS Description You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data stru…
Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 849    Accepted Submission(s): 204 Problem Description Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯…
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…
Distance on the tree DSM(Data Structure Master) once learned about tree when he was preparing for NOIP(National Olympiad in Informatics in Provinces) in Senior High School. So when in Data Structure Class in College, he is always absent-minded about…