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
|
void solve() {
int n, m;
cin >> n >> m;
vi l(n);
vvi ma;
rep(i, 0, n - 1) {
cin >> l[i];
vi tem(l[i]);
rep(j, 0, l[i] - 1) cin >> tem[j];
ma.push_back(tem);
}
vi tem(m + 1);
int ans = 0;
rep(i, 0, n - 1) {
for (int& p : ma[i]) tem[p]++;
}
bool pd = true;
rep(i, 1, m) {
if (tem[i] == 0) {
cout << "NO" << endl;
return;
}
}
rep(i, 0, n - 1) {
bool flag = true;
for (int& p : ma[i]) {
if (tem[p] == 1) {
flag = false;
break;
}
}
if (flag) ans++;
}
if (ans >= 2)
cout << "YES" << endl;
else
cout << "NO" << endl;
return;
}
|