forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprerequisites.cpp
44 lines (37 loc) · 907 Bytes
/
prerequisites.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
while(cin >> n && n != 0 && cin >> m) {
unordered_set<string> taken;
for(int i = 0; i < n; i++) {
string s;
cin >> s;
taken.insert(s);
}
bool works = true;
for(int i = 0; i < m; i++) {
int count, needed;
cin >> count >> needed;
int have = 0;
for(int j = 0; j < count; j++) {
string s;
cin >> s;
if(taken.count(s) > 0) {
have++;
}
}
if(have < needed) {
works = false;
}
}
if(works) {
cout << "yes" << endl;
}
else {
cout << "no" << endl;
}
}
}