UVa 10919 Prerequisites

 1  #include <stdio.h>
 2  #include <stdlib.h>
 3  #include <iostream>
 4  #include <algorithm>
 5  #include <map>
 6  using namespace std;
 7  int main()
 8  {
 9      int k,m;
10      while(cin>>k && k!=0)
11      {
12          cin>>m;
13          map<string,int> course;
14          for(int i=0;i<k;i++)
15          {
16              string str;
17              cin>>str;
18              course[str]=1;
19          }
20          bool check=true;
21          for(int i=0;i<m;i++)
22          {
23              int n;
24              int limit,reg=0;
25              cin>>n>>limit;
26              for(int j=0;j<n;j++)
27              {
28                  string str;
29                  cin>>str;
30                  if(course[str]==1) reg+=1;
31              }
32              if(reg<limit)
33              {
34                  check=false;
35              }
36          }
37          if(check==false) cout<<"no"<<endl;
38          else cout<<"yes"<<endl;
39 
40      }
41      return 0;

42  }

留言

這個網誌中的熱門文章

Things a Little Bird Told Me: Confessions of the Creative Mind

UVa 12970 Alcoholic Pilots

UVa 483 Word Scramble