首页 > 代码库 > NYOJ 120 校园网络

NYOJ 120 校园网络

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=120

 

思路:超级水题~,结果 = 出度为0的点的数量+入度为0的点的数量。。

 

代码:

#include <iostream>#include <cstring>using namespace std;int book1[101];int book2[101]; int main(){    int num;    int n;    int temp;    cin>>num;    int res;    while(num--)    {        res = 0;        cin>>n;        memset(book1,0,sizeof(book1));                memset(book2,0,sizeof(book2));        for(int i=1;i<=n;i++)        {            while(cin>>temp&&temp!=0)            {                book1[temp]++;                book2[i]++;            }        }                for(int i=1;i<=n;i++)        {            if(book1[i]==0)                res++;            if(book2[i]==0)                res++;         }        cout<<res<<endl;    }    return 0;} 

 

NYOJ 120 校园网络