access
void access(int x) {
int y=0;
while (x) {
splay(x,0);
f[t[x][1]]=0;p[t[x][1]]=x;
t[x][1]=y;f[y]=x;p[y]=0;
updata(x);
y=x;x=p[x];
}
}
makeroot
void makeroot(int x) {
access(x);splay(x,0);rev[x]^=1;
}
link
void link(int x,int y) {
makeroot(x);p[x]=y;
}
cut
void cut(int x,int y) {
makeroot(x);access(y);splay(y,0);
t[y][0]=0;f[x]=p[x]=0;
updata(y);
}

本文介绍了一种基于树状结构的数据操作方法,包括访问指定节点、更改根节点、链接及切断节点之间的关系等基本操作。
3437

被折叠的 条评论
为什么被折叠?



