#include #include #include #include #include using namespace std; map mapName; //name--integer //并查集的数据存储 #define LENMAX 1000005 int father[LENMAX]; //并查集的查找操作 int Find(int x) { if(x==father[x]) return x; else { father[x]=Find(father[x]); //压缩路径compress path return father[x]; } } //并查集的合并操作 void Union(int x,int y) { int tmpX=Find(x); int tmpY=Find(y); if(tmpX!=tmpY) father[tmpX]=tmpY; /* * 合并的时候取小的数值 if(tmpXtmpY) father[tmpX]=tmpY; */ } //初始化并查集 void InitFather() { int i; for(i=0;i