Collection of common mistakes

LCT

 

splay only turns twice when the parent node of the point is not the root node

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

 

When accessing, the node needs to be transferred to the global root, so the loop boundary is x==0

And when splaying, just go to the current root.

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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325047753&siteId=291194637