@[风人](/user/293527) 合并两个集合是连Getfather而不是自己
by Prean @ 2020-05-10 09:19:46
把
```
father[a[i].x] = a[i].y;
```
改为
```
father[getfather(a[i].x)] = getfather(a[i].y);
```
by pikabi @ 2020-05-10 09:19:48
@[limaopipi2022](/user/160839) 明白!谢谢
by 风人 @ 2020-05-10 09:20:38
@[pikabi](/user/209604) 好的,谢谢
by 风人 @ 2020-05-10 09:20:52
```cpp
father[a[i].x] = a[i].y;
```
改成
```cpp
father[getfather(a[i].x)]=getfather(a[i].y);
by Prean @ 2020-05-10 09:20:56
@[limaopipi2022](/user/160839) okk,谢谢您
by 风人 @ 2020-05-10 09:22:28
@[limaopipi2022](/user/160839) 啊,好像不光错在这,我的getfather一直返回0
by 风人 @ 2020-05-10 09:25:09
@[风人](/user/293527) 可以写一种~~压行~~简单的getfather(我用find代替)
```cpp
int find(int a){return f[a]==a?a:f[a]=find(f[a]);}
by Prean @ 2020-05-10 09:26:42
@[limaopipi2022](/user/160839) 好的谢谢,我把ios::sync_with_stdio(0);去掉后好了,这是个假的优化??
by 风人 @ 2020-05-10 09:35:58
@[风人](/user/293527) 不是啊,ios关闭同步流,cin会比scanf快很多
by Prean @ 2020-05-10 09:40:00