求助FHQ
  • 板块学术版
  • 楼主Prean
  • 当前回复16
  • 已保存回复16
  • 发布时间2020/7/25 09:02
  • 上次更新2023/11/6 22:21:20
查看原帖
求助FHQ
160839
Prean楼主2020/7/25 09:02

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;
    }
}
2020/7/25 09:02
加载中...