p4197专题

P4197 Peaks [Kruskal 重构树 + 主席树]

传送门 从小到大排, kruskal重构 , 每次倍增找到值刚好小于等于要求的点 , 问题转化为子树内的第k大 静态子树k大, 不就是主席树吗 #include<bits/stdc++.h>#define N 200050#define M 500050using namespace std;int first[N],next[M],to[M],tot;struct Node{int