```diff
@@ -52,7 +52,7 @@
int findx=find(x);
int findy=find(y);
if(findx==findy)continue;
- root[x]=root[y]=merge(findx,findy);
+ root[findx]=root[findy]=merge(findx,findy);
}
if(op==2)
{
@@ -65,6 +65,7 @@
printf("%d\n",tree[findx].val);
del[findx]=1;
root[findx]=merge(tree[findx].ls,tree[findx].rs);
+ root[tree[findx].ls]=root[tree[findx].rs]=root[findx];
tree[findx].ls=tree[findx].rs=tree[findx].dist=0;
}
}
```
第一处看起来是笔误;第二处没更新子节点导致 `find` 死递归,用样例就可发现。
by ud2_ @ 2023-03-01 23:54:49
@[ud2_](/user/206953) Thanks
by __vector__ @ 2023-03-02 13:31:43