为什么这样就会RE
node *find_rank(int x){
node *now=root;
while(1){
if(now->lson){
if(x<=now->lson->size)
now=now->lson;
else if(x==now->lson->size+1)
break;
else{
now=now->rson;
x-=(now->lson->size+1);
}
}
else{
if(x==1)
break;
else{
now=now->rson;
x--;
}
}
}
splay(now,root);
root=now;
return now;
}
然后变成
node *find_rank(int x){
node *now=root;
while(1){
if(now->lson){
int t=now->lson->size;
if(x<=t)
now=now->lson;
else if(x==t+1)
break;
else{
now=now->rson;
x-=(t+1);
}
}
else{
if(x==1)
break;
else{
now=now->rson;
x--;
}
}
}
splay(now,root);
root=now;
return now;
}
他就AC了 (大雾