• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            #include <iostream>
            #include 
            <cstdio>

            const int maxn = 30000 + 5;

            using namespace std;

            int father[maxn],rank[maxn];

            void init( int n )
            {
                
            for ( int i = 0; i < n; i++)
                {
                    father[i] 
            = i;
                    rank[i] 
            = 1;
                }
            }

            int findSet( int n )
            {
                
            if(father[n] != n)
                    father[n] 
            = findSet(father[n]);
                
            return father[n];
            }

            void Union( int a, int b )
            {
                
            int x = findSet( a );
                
            int y = findSet( b );

                
            if( x == y ) return ;
                
            if( rank[x] >= rank[y] )
                {
                    father[y] 
            = x;
                    rank[x] 
            += rank[y];
                }
                
            else
                {
                    father[x] 
            = y;
                    rank[y] 
            += rank[x];
                }
            }

            int main()
            {
                
            int m, n, count, temp, first;
                
            while~scanf("%d%d"&n, &m ) && n )
                {
                    init(n);
                    
            while( m-- )
                    {
                        scanf(
            "%d%d"&count, &first );
                        
            forint i = 1; i < count ;i ++)
                        {
                            scanf(
            "%d"&temp);
                            Union( first, temp );
                        }
                    }
                    printf(
            "%d\n",rank[findSet(0)]);
                }
                
            return 0;
            }
            posted on 2010-07-29 07:09 Vontroy 閱讀(257) 評論(0)  編輯 收藏 引用 所屬分類: 并查集POJ
            国产成人香蕉久久久久| 久久亚洲精品无码VA大香大香| 亚洲国产精品无码久久98| 久久久一本精品99久久精品88| 久久人爽人人爽人人片AV| 久久精品国产99久久久香蕉| 一本色道久久综合亚洲精品| 伊人久久精品线影院| 国内精品久久久久影院薰衣草 | 久久免费观看视频| 精品久久久久久久国产潘金莲| 老色鬼久久亚洲AV综合| 久久亚洲国产精品五月天婷| 久久精品无码专区免费青青| 日韩va亚洲va欧美va久久| 久久人人爽人人爽人人片AV不 | 久久久久久久综合日本| 久久天天躁狠狠躁夜夜网站| 久久久黄片| 国产精品成人精品久久久| av无码久久久久不卡免费网站| 久久精品国产99国产精品导航 | 亚洲AV无码1区2区久久| 久久久久婷婷| 国内精品久久久久久久亚洲| 久久福利青草精品资源站| 亚洲国产精品无码久久久不卡| 中文字幕精品久久久久人妻| 久久综合九色欧美综合狠狠 | 国产精品成人久久久久久久| 国内精品九九久久久精品| 日韩精品久久无码中文字幕| 国产精品乱码久久久久久软件 | 国产成人综合久久综合| 中文国产成人精品久久不卡| 亚洲精品无码久久久| 免费精品久久天干天干| 欧美日韩久久中文字幕| 国产69精品久久久久久人妻精品| 精品久久久一二三区| 人妻精品久久无码专区精东影业|