• <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>
            posts - 100,  comments - 15,  trackbacks - 0
             1#include<iostream>
             2using namespace std;
             3#define MAXN 30000
             4#define MAXM 500
             5
             6int parent[MAXN];
             7
             8void init(int n=MAXN)
             9{
            10    int i;
            11    for(i=0;i<n;i++)
            12        parent[i]=-1;
            13}

            14int find(int x)
            15{
            16    if(parent[x]<0)
            17        return x;
            18    else return parent[x]=find(parent[x]);
            19}

            20
            21int Union(int x,int y)
            22{
            23    int root1=find(x),
            24        root2=find(y);
            25    if(root1==root2) return root1;
            26    if(parent[root1]<parent[root2])
            27    {
            28        parent[root1]+=parent[root2];
            29        parent[root2]=root1;
            30        return root1;
            31    }
            else{
            32        parent[root2]+=parent[root1];
            33        parent[root1]=root2;
            34        return root2;
            35    }

            36}

            37int main()
            38{
            39    int n,m,i,j,k,x,root;
            40    while( scanf("%d%d",&n,&m)==2 && n!=0 )
            41    {
            42        init(n);
            43        for(i=0;i<m;i++)
            44        {
            45            scanf("%d",&k);
            46                for(j=1;j<=k;j++)
            47                {
            48                    scanf("%d",&x);
            49                    if(j==1) root=x;
            50                    root=Union(root,x);
            51                }

            52        }

            53        printf("%d\n",-parent[find(0)]);
            54    }
                    
            55    return 0;
            56}
            posted on 2009-04-22 20:16 wyiu 閱讀(198) 評論(0)  編輯 收藏 引用 所屬分類: POJ
            久久无码人妻精品一区二区三区| 久久亚洲AV成人出白浆无码国产| 久久五月精品中文字幕| 9999国产精品欧美久久久久久| 91麻豆精品国产91久久久久久| 久久精品成人影院| 国产精品乱码久久久久久软件| 亚洲伊人久久综合中文成人网| 久久综合精品国产一区二区三区 | 久久水蜜桃亚洲av无码精品麻豆| 国产A级毛片久久久精品毛片| 欧美亚洲色综久久精品国产 | 中文字幕成人精品久久不卡| 99久久精品这里只有精品 | 办公室久久精品| 亚洲欧美日韩精品久久亚洲区| 老色鬼久久亚洲AV综合| 久久婷婷成人综合色综合| 久久精品国产99国产精品| 久久精品aⅴ无码中文字字幕不卡| 精品多毛少妇人妻AV免费久久| 77777亚洲午夜久久多喷| 91精品国产高清久久久久久91 | 色综合久久无码中文字幕| 久久99国产综合精品| 少妇人妻综合久久中文字幕| 99久久伊人精品综合观看| 72种姿势欧美久久久久大黄蕉| 亚洲精品乱码久久久久久蜜桃图片 | 无码人妻少妇久久中文字幕蜜桃| 久久国产综合精品五月天| 亚洲欧美成人综合久久久| 中文成人久久久久影院免费观看| 精品多毛少妇人妻AV免费久久 | 久久亚洲国产最新网站| 99久久免费国产精精品| 久久亚洲精品无码AV红樱桃| 亚洲伊人久久精品影院| 久久精品国产99国产精品亚洲| 国产香蕉久久精品综合网| 国产成人AV综合久久|