codeforces 615A

题意:给你m个编号为1到m的灯泡;然后n行中每一行的第一个数给出打开灯泡的个数xi  然后是yij是每个灯泡的编号;

   题目中有一句话、 我愣是没看,因为我英语真的是一窍不通,看了也白看,直接看数据做的,就是因为这个送了2发;

   If Vasya presses the button such that some bulbs connected to it are already turned on, they do not change their state, i.e. remain turned on.

     这句话是说每次打开灯泡之后灯泡就保持打开的状态,即使一个编号的灯泡在不同的两行出现了 灯泡也是打开状态的;

   题目就问最后的灯泡最后是不是全是开打状态;  转化一下就是判断1到m个灯泡的编号是否都出现过;

    

 1 #include<bits/stdc++.h>
 2 int num[105];
 3 using namespace std;
 4 int  main()
 5 {
 6     int n,m;
 7     cin >> n >> m;
 8     memset(num,0,sizeof(num));
 9     for(int j,i=0;i<n;++i){
10         int x,y;
11         cin  >> x;
12         for(int j=0;j<x;++j){
13             cin >> y;    num[y]++;
14         }
15     }
16     int p=1;
17     for(int i=1;i<=m;++i)    if(num[i]==0){p=0;break;
18     }
19     if(p)    cout << "YES\n";
20     else    cout << "NO\n";
21 } 

 

posted @ 2016-01-08 23:39  我不萌、我要高冷  阅读(352)  评论(0编辑  收藏  举报