并查集模板代码
#include<bits/stdc++.h>
using namespace std;
int n = 1005;
vector<int> father = vector<int>(n,0);
//初始化
void init(){
for(int i=0;i<father.size();i++){
father[i] = i;
}
}
//寻根过程
int find(int u){
return father[u]==u?u:father[u]=find(father[u]);
}
//判断是否是同一个根
bool isSame(int u,int v){
u = find(u);
v = find(v);
if(u==v) return true;
else return false;
}
//将某一条边加入并查集中
void join(int u,int v){
u = find(u);
v = find(v);
if(u==v) return;
father[u] = v;
}
int main(){
}