题目链接 思路和bzoj2141差不多,不过这道题的数据更强一些,线段树套treapT了,树状数组套treap卡过~~ #include<bits/stdc++.h> using namespace std; typedef long long ll; ,inf=0x3f3f3f3f; ][],val[N*],siz[N*],rd[N*],tot,a[N],b[N]; ll ans; ]]+siz[ch[u][]]+;} ,val[u]=x,rd[u]=rand(),ch[u][]=ch[u]…