Problem H. Cups and Beans 2017.8.11 原题: There are N cups numbered 0 through N − 1. For each i(1 ≤ i ≤ N − 1), the cup i contains Ai beans,and this cup is labeled with an integer Ci.Two people will play the following game:• In each turn, the player ch…
ittle w and Discretization 主席树维护Mex. 每个右端点 r 维护出一棵 在[1, r ] 区间中 其他所有的 值离这个 r 最近的的位置是多少. 然后询问区间[L,R]的时候,从rt[R] 出发,然后如果左儿子的中所有出线位置的最小值 >= L, 则说明他们所有的点都出线在这个区间内了,然后往右走. 否则就说明左边有点没有出线过,需要往左走. 代码: #include<bits/stdc++.h> using namespace std; #define F…
BZOJ_1803_Spoj1487 Query on a tree III_主席树 Description You are given a node-labeled rooted tree with n nodes. Define the query (x, k): Find the node whose label is k-th largest in the subtree of the node x. Assume no two nodes have the same labels. I…