原题链接:
简单记录下并查集的模板
#include#include #include #include #include #include #include #include #define ll long long#define pi 3.1415927using namespace std;int fat[30005];int finds(int n){ //查找 if(fat[n]==n) return n; return fat[n]=finds(fat[n]); //路径压缩}void join(int a, int b){ //合并 int j=finds(a), k=finds(b); if(j