关于splay
  • 板块学术版
  • 楼主technology_s
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/4/6 18:03
  • 上次更新2024/4/6 20:22:37
查看原帖
关于splay
1061770
technology_s楼主2024/4/6 18:03

为何查询 xx 的排名这样写会死循环?

int find_key(int x){
	int ret=0,now=rt;
	while(1){
		if(x<num[now]){
			now=son[now][0];
		}else{
			if(son[now][0]>=1){
				ret+=sz[son[now][0]];
			}if(x==num[now]){
				Splay(now);
				return ret+1;
			}ret+=cnt[now];
			now=son[now][1];
		}
	}
}
2024/4/6 18:03
加载中...