int fath[N];
int Find(int x) {
if(x != fath[x]) fath[x] = Find(fath[x]);
return fath[x];
}
void Union(int x, int y) {
int fx = Find(x), fy = Find(y);
if(fx != fy)
fath[fy] = fx;
}
并查集模板[路径压缩]
最新推荐文章于 2024-02-03 11:27:56 发布