https://www.luogu.org/problem/P3203 分析 还有个模板不想写题解了,反正这题也差不多是个模板 可以将一个点往后跳跃到的点连起来,跳出去的连到根节点+1,这就是棵树 要求支持删边连边和求根节点到这里的深度?LCT完全可以胜任 就是个板子,深度不用特别思考,Split直接提出来的是链,求Splay大小即可 #include <iostream> #include <cstdio> using namespace std; const int N=2e5+10; struct Node { int f,c[2],s,rev; }t[N]; int stk[N],top,v[N]; int n,m; bool Witch(int x) {return x==t[t[x].f].c[1];} bool Check_Root(int x) {return t[t[x].f].c[0]==x||t[t[x].f].c[1]==x;} void Reverse(int x) {swap(t[x].c[0],t[x].c[1]),t[x].rev^=1;} void Pushdown(int x) {if (t[x].rev) Reverse(t[x].c[0]),Reverse(t[x].c[1]),t[x].rev=0;} void Update(int x)