跳到正文

个人记录

LCT 简记

Pawbert约 1 分钟
原文
文章信息与版本

文章信息

发布
2022年8月9日
收录
2025年12月12日
更新
2026年11月10日
篇幅
约 1 分钟
获赞
1

版本

  1. v1当前

贯穿全文的重点:每个 Splay 中维护的节点按中序遍历得到的顺序在原树中深度依次增加 1。

access(x)\tt access(x) :把根节点到 xx 的路径上的边变为实边。

findRoot(x)\tt findRoot(x) :找到 xx 在原树中的根(根节点在 Splay 中的中序遍历为 1,向左找即可)

makeRoot(x)\tt makeRoot(x) :将 xx 设置为整棵树的根。(相当于将路径 x→rtx\to rt 改为 rt→xrt\to x,对应的就是将维护 x→rtx\to rt 这条实链的 Splay 整体翻转)

spilt(x,y)\tt spilt(x, y) :维护 x→yx\to y 的路径。(makeRoot(x)\tt makeRoot(x) 然后打通 access(y)\tt access(y),直接 splay(y)\tt splay(y) 然后维护子树信息)

link(x,y)\tt link(x, y) :连接 x→yx \to y。(直接 makeroot(x)\tt makeroot(x) 然后改父亲即可)

cut(x,y)\tt cut(x, y) :切断 x→yx\to y 的边(先 makeRoot(x)\tt makeRoot(x),此时保证 xx 在 Splay 中中序遍历为 1,然后 access(y),splay(y)\tt access(y),splay(y),这些操作都包含在 findRoot(y)\tt findRoot(y) 中。因为 findRoot(y)\tt findRoot(y) 中 splay(x)\tt splay(x) 过,且中序遍历没发生改变,所以 yy 一定是 xx 的右儿子。然后一堆判断就好了)

其他没什么好总结,因为光光 cut(x,y)+makeRoot(x)\tt cut(x, y) + makeRoot(x) 就搞了 1h+,学了一个晚上搞得我心情很不好。

原文
存档评论1 条抓取于