为何错了50分

P1983 [NOIP2013 普及组] 车站分级

睡在墙上的猫 @ 2016-10-01 10:48:00

#include<iostream>
#include<cstring>
using namespace std;
bool flag[1001]={false};
int a[1001][1001],n,m,p[1001][1001],ru[1001],vis[1001],dui[1001],front=1,rear=1;
void creat()
{
    int i,j,t,k,i1;
    cin>>n>>m;
    for (i=1;i<=m;i++)
    {
        memset(flag,false,sizeof(flag));
        cin>>a[i][0];
        for (j=1;j<=a[i][0];j++)
        {
            cin>>a[i][j];
            flag[a[i][j]]=true;
        }
        for (k=a[i][1];k<=a[i][a[i][0]];k++)
        {
            if (flag[k]==true)
            {
                for (i1=a[i][1];i1<=a[i][a[i][0]];i1++)
                {
                    if (flag[i1]==false) p[i1][k]=1;
                } 
            }
        } 
    }
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
        {
            if (p[j][i]==1) ru[j]++;
        }
    }
} 
void tuopu()
{
    int i,j,book[1000]={0},ans=0;
    for (i=0;i<n;i++)
    {
        for (j=1;j<=n;j++)
        if (ru[j]==i) book[i]++;
    }
    for (i=0;i<n;i++)
    {
        if (book[i]) ans++;
    }
    cout<<ans;
}
int main()
{
    creat();
    tuopu();
    return 0;
}

|