并查集不是这么写的。。吧?
by Loic_ @ 2023-05-14 00:56:09
并查集写错了,常用模板是:
```cpp
int find(int x){
if(fa[x]==x)return x;
else return fa[x]=find(fa[x]);
}
```
by HeCao2008 @ 2023-05-14 02:45:28
@[HeCao2008](/user/422996) 并查集没错,这是非递归的并查集写法
by ForgotDream_CHN @ 2023-05-14 07:31:37
jiangly 就是这么写的
by ForgotDream_CHN @ 2023-05-14 07:31:51
@[秋天的小溪123](/user/536809) 数组开小了
by ForgotDream_CHN @ 2023-05-14 07:32:32
还有,不连通的时候要特判
by ForgotDream_CHN @ 2023-05-14 07:33:55
@[ForgotDream_CHN](/user/750067) ???前一天晚上我脑子出问题了,确实没错,我也不知道我为什么认为这是错的![](//图.tk/8)
by HeCao2008 @ 2023-05-14 07:43:56
oh,谢谢
by 秋天的小溪123 @ 2023-05-14 12:17:27