关于Splay
  • 板块学术版
  • 楼主Noir_
  • 当前回复18
  • 已保存回复18
  • 发布时间2021/5/4 10:44
  • 上次更新2023/11/4 23:45:40
查看原帖
关于Splay
100743
Noir_楼主2021/5/4 10:44

这两种写法为什么第一种是对的,第二种就会炸?

(就是那个f=fa[x]的位置)

inline void splay(int x){
    for(int f;f=fa[x];rotate(x)) 
    	if(fa[f]){
            if(get_son(x)==get_son(f)) 
                rotate(f);
            else rotate(x);
        }
    root=x;
}


inline void splay(int x){
    for(int f;f;rotate(x)){
        f=fa[x];
        if(fa[f]){
            if(get_son(x)==get_son(f)) 
                rotate(f);
            else rotate(x);
        }
    } 
    root=x;
}
2021/5/4 10:44
加载中...