RT,每次我写排名分裂就会WA掉。。。全WA。。。
有人能康康怎么回事吗/kel
void update(int u){
siz[u]=siz[chi[u][0]]+siz[chi[u][1]]+1;
}
void split(int u,int k,int&x,int&y){
if(!u)return void(x=y=0);
if(k<=siz[chi[u][0]])split(chi[y=u][0],k,x,chi[u][0]);
else split(chi[x=u][1],k-siz[chi[u][0]]-1,chi[u][1],y);
update(u);
}
int merge(int x,int y){
if(!x||!y)return x|y;
if(rnd[x]<rnd[y]){
chi[x][1]=merge(chi[x][1],y);
update(x);
return x;
}
else{
chi[y][0]=merge(x,chi[y][0]);
update(y);
return y;
}
}