•  



    int getfather(int v){
        if (father[v]==v)
           return v;
        return father[v]=getfather(father[v]);
    }

    void judge(int x ,int y)
     
    {
         fx = getfather(x);
         fy = getfather(y);
     
         if (rank[fx]>rank[fy])
            father[fy] = fx;
         else
         {
            father[fx] = fy;
            if(rank[fx]==rank[fy])
               inc(rank[fy]);
         }
    }

     

    初始化:

    memset(rank,0,sizeof(rank));