kruskal跟spfa一样可能被卡的 (USACO经常卡一些算法
by 哔哩哔哩 @ 2018-11-02 15:47:52
@[哔哩哔哩](/space/show?uid=41868) 诶,是这样嘛,可是题解里都是用kruskal做的呀,而且还能A,莫非真的是我RP问题【无奈】
by csath99 @ 2018-11-02 15:55:05
@[csath99](/space/show?uid=1470) gf那里优化一下就好了(应该
by 哔哩哔哩 @ 2018-11-02 15:56:31
```
return fa[x]==x?x:find(fa[x]);
```
没有路径压缩
by Floatiy @ 2018-11-02 15:56:49
```cpp
int find(int x)
{
return fa[x]==x?x:f[x]=find(fa[x]);
}
```
by 哔哩哔哩 @ 2018-11-02 15:56:53
@[csath99](/space/show?uid=1470) (显然这题没卡kruskal
by 哔哩哔哩 @ 2018-11-02 15:57:19
@[csath99](/space/show?uid=1470) getfather改成我发的那个应该就可以了
by 哔哩哔哩 @ 2018-11-02 15:59:03
恭喜 你A了
by 哔哩哔哩 @ 2018-11-02 15:59:21
@[四向搜](/space/show?uid=52200) 谢谢啦
by csath99 @ 2018-11-02 15:59:36
@[哔哩哔哩](/space/show?uid=41868) 谢谢啦
by csath99 @ 2018-11-02 15:59:54