数据害人不浅!

P3391 【模板】文艺平衡树

yyc_ @ 2023-03-18 16:03:42

Splay.

如果旋转时,不判断祖孙三代是否在一条直线上,而是

void splay(int x) {
  for (int f = fa[x]; f = fa[x], f; rotate(x))
    if (fa[f]) rotate(/*get(x) == get(f)*/ 0 ? f : x);
  rt = x;
}

by yyc_ @ 2023-03-18 16:03:58

也能过


|