常见错误锦集

LCT

splay只有该点的父亲节点不是根节点的时候才转两次

    for(int y = fa(x); !IsRoot(x); rotate(x), y = fa(x))
        if(!IsRoot(y))//注意 
            rotate( ident(x) == ident(y) ? y : x );

access的时候需要将节点转到全局的根,所以循环边界为x==0

而splay的时候只要转到当前根就可以了

  access:  for(int y = 0; x; x = fa(y = x))
 splay: for(int y = fa(x); !IsRoot(x); rotate(x), y = fa(x))

猜你喜欢

转载自www.cnblogs.com/zwfymqz/p/8971359.html
今日推荐