RE求解
查看原帖
RE求解
219935
JeffWang2019楼主2020/7/5 10:08
#include <bits/stdc++.h>
using namespace std;
int a[101];//int c[101];
int n,m,k,cnt=0;
bool f[101][101];
bool b=false,d=false,bb=true;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        b=false;
        scanf("%d",&k);
        for(int j=1;j<=k;j++)
        {
            scanf("%d",&a[j]);
            if(a[j]==1)
            {
                b=true;
            }
        }
        if(b)
        {
            cnt++;
            for(int j=1;i<=k;j++)
            {
                f[a[j]][cnt]=true;
                //c[a[j]]++;
            }
        }
        else
        {
            //int cnt2=0;
            for(int j=1;j<=cnt;j++)
            {
                for(int o=1;o<=k;o++)
                {
                    if(f[a[o]][j])
                    {
                        d=true;
                        break;
                    }
                }
                if(d)
                {
                    for(int o=1;o<=k;o++)
                    {
                        f[a[o]][j]=true;
                    }
                }
            }
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(!f[j][cnt])
            {
                bb=false;
                break;
            }
        }
        if(bb)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}
2020/7/5 10:08
加载中...