const int N=120; int father[N]; int rank1[N]; void init(int Size) { for(int i=1;i<=Size;++i) father[i]=i,rank1[i]=0; } int Find(int x) { while(x!=father[x]) x=father[x]; return x; } bool Union(int x,int y) { int fx,fy; fx=Find(x),fy=Find(y); if(fx==fy) return false; else if(rank1[fx]>=rank1[fy]) { father[fy]=fx; rank1[fx]+=rank1[fy]; } else { father[fx]=fy; rank1[fy]+=rank1[fx]; } return true; }