First:并查集个人简介
并查集,字Union-Find,数据结构,简单,代表作【模板】并查集, 亲戚等
Second:并查集之中文代码
C++#include <bits/stdc++.h>
using namespace std;
int find_father(int x){//找爸爸??????????????????????????????????????
if (fa[x] == x) return x;
return fa[x] = find_father(fa[x]);//爸爸的爸爸是爸爸???????????????
}
int fa[100005], n;
int main(){
cin >> n;
for (int i = 1; i <= n; i++)
fa[i] = i;//我爹是我?????????????????????????????????
return 0;
}
Third:并查集的强大
∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑
可以并为
∑
也可以查到
∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑∑
Fourth并查集的进化史
The end
感谢大家对Union-Find的支持