版本比较
并查集
正文
增加 7 行删除 7 行
36 行未改动373839404141424344454546474849505147484950515253545574 行未改动36 行未改动
```cppconst int N = 1e3 + 5;
int n,m,fa[N],u,v,cnt;int n, m, fa[N], u, v, cnt;
int popu[N];//存集合大小
inline int find(int x){return x == fa[x] ? x : fa[x] = find(fa[x]);}inline int find (int x) { return x == fa[x] ? x : fa[x] = find(fa[x]);}
inline void unite(int x,int y){ int fx = find(x),fy = find(y); if(fx != fy){ if(popu[fx] >= popu[fy]) fa[fy] = fx,popu[fx] += popu[fy]; else fa[fx] = fy,popu[fy] += popu[fx];inline void unite (int x, int y) { int fx = find(x), fy = find(y); if (fx != fy) { if(popu[fx] >= popu[fy]) fa[fy] = fx, popu[fx] += popu[fy]; else fa[fx] = fy, popu[fy] += popu[fx]; }}```
74 行未改动