标签:vector int c++ 合并 turn clu == 初始化 cto
很简单,但是还是想记一下
#include <numeric>
vector<int> father(MAX);
iota(father.begin() + 1, father.end(), 1);
int findFather(int u) {
if (father[u] == u)
return u;
else {
int f = findFather(father[u]);
father[u] = f;
return f;
}
}
void merge(int a, int b) {
int aF = findFather(a), bF = findFather(b);
if (aF != bF) father[aF] = bF;
}
标签:vector int c++ 合并 turn clu == 初始化 cto
原文地址:https://www.cnblogs.com/mostiray/p/13341697.html