// UVa 10919 - Prerequisites? #include <iostream> #include <map> using namespace std; int main() { int n, m; while (cin >> n >> m && n) { map<int, bool> taken; for (int i = 0; i < n; i++) { int a; cin >> a; taken[a] = true; } bool possible = true; for (int i = 0; i < m; i++) { int tot, need; cin >> tot >> need; for (int i = 0; i < tot; i++) { int a; cin >> a; if (taken[a]) need--; } if (need > 0) possible = false; } if (possible) cout << "yes" << endl; else cout << "no" << endl; } return 0; }
No comments:
Post a Comment