#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(v) begin(v), end(v)
int main() {
int n, k; cin >> n >> k;
vector<unordered_set<int>> g(n);
rep (i, n) {
int d; cin >> d;
rep (j, d) {
int a; cin >> a;
g[i].insert(a);
}
}
vector<int> deg(n);
vector<bool> used(n, false);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
rep (i, n) {
deg[i] = g[i].size();
que.emplace(deg[i], i);
}
int ans = 0;
while (!que.empty()) {
auto [d, v] = que.top(); que.pop();
if (deg[v] != d) continue;
vector<int> a;
for (auto i : g[v]) {
if (used[i]) continue;
a.push_back(i);
}
int m = a.size();
rep (bt, 1 << m) {
vector<int> b;
rep (i, m) if (bt >> i & 1) b.push_back(a[i]);
rep (i, b.size()) rep (j, i) {
if (g[b[i]].count(b[j]) == 0) goto END;
}
ans = max(ans, __builtin_popcount(bt) + 1);
END:;
}
used[v] = true;
for (auto i : g[v]) {
if (used[i]) continue;
--deg[i];
que.emplace(deg[i], i);
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
1624 KB |
Output is correct |
4 |
Correct |
5 ms |
1628 KB |
Output is correct |
5 |
Correct |
5 ms |
1748 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
5 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
1624 KB |
Output is correct |
4 |
Correct |
5 ms |
1628 KB |
Output is correct |
5 |
Correct |
5 ms |
1748 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
5 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
5 ms |
1624 KB |
Output is correct |
12 |
Correct |
5 ms |
1700 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
1628 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
5 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
1528 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
1372 KB |
Output is correct |
21 |
Correct |
4 ms |
1552 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
6 ms |
1784 KB |
Output is correct |
26 |
Correct |
6 ms |
1628 KB |
Output is correct |
27 |
Correct |
5 ms |
1572 KB |
Output is correct |
28 |
Correct |
6 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
7 ms |
1628 KB |
Output is correct |
31 |
Correct |
7 ms |
1772 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
6 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1768 KB |
Output is correct |
35 |
Correct |
3 ms |
1112 KB |
Output is correct |
36 |
Correct |
3 ms |
1136 KB |
Output is correct |
37 |
Correct |
3 ms |
1112 KB |
Output is correct |
38 |
Correct |
2 ms |
860 KB |
Output is correct |
39 |
Correct |
2 ms |
860 KB |
Output is correct |
40 |
Correct |
10 ms |
2088 KB |
Output is correct |
41 |
Correct |
2 ms |
860 KB |
Output is correct |
42 |
Correct |
10 ms |
1884 KB |
Output is correct |
43 |
Correct |
9 ms |
2124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
856 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
374 ms |
28332 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
375 ms |
27768 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
375 ms |
27704 KB |
Output is correct |
16 |
Correct |
374 ms |
27648 KB |
Output is correct |
17 |
Correct |
381 ms |
27948 KB |
Output is correct |
18 |
Correct |
369 ms |
27744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
1624 KB |
Output is correct |
4 |
Correct |
5 ms |
1628 KB |
Output is correct |
5 |
Correct |
5 ms |
1748 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
5 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
5 ms |
1624 KB |
Output is correct |
12 |
Correct |
5 ms |
1700 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
1628 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
5 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
1528 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
1372 KB |
Output is correct |
21 |
Correct |
4 ms |
1552 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
6 ms |
1784 KB |
Output is correct |
26 |
Correct |
6 ms |
1628 KB |
Output is correct |
27 |
Correct |
5 ms |
1572 KB |
Output is correct |
28 |
Correct |
6 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
7 ms |
1628 KB |
Output is correct |
31 |
Correct |
7 ms |
1772 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
6 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1768 KB |
Output is correct |
35 |
Correct |
3 ms |
1112 KB |
Output is correct |
36 |
Correct |
3 ms |
1136 KB |
Output is correct |
37 |
Correct |
3 ms |
1112 KB |
Output is correct |
38 |
Correct |
2 ms |
860 KB |
Output is correct |
39 |
Correct |
2 ms |
860 KB |
Output is correct |
40 |
Correct |
10 ms |
2088 KB |
Output is correct |
41 |
Correct |
2 ms |
860 KB |
Output is correct |
42 |
Correct |
10 ms |
1884 KB |
Output is correct |
43 |
Correct |
9 ms |
2124 KB |
Output is correct |
44 |
Correct |
64 ms |
2652 KB |
Output is correct |
45 |
Correct |
0 ms |
344 KB |
Output is correct |
46 |
Correct |
12 ms |
2148 KB |
Output is correct |
47 |
Correct |
22 ms |
3040 KB |
Output is correct |
48 |
Correct |
10 ms |
2140 KB |
Output is correct |
49 |
Correct |
21 ms |
3164 KB |
Output is correct |
50 |
Correct |
22 ms |
3416 KB |
Output is correct |
51 |
Correct |
178 ms |
5172 KB |
Output is correct |
52 |
Correct |
5 ms |
1628 KB |
Output is correct |
53 |
Correct |
320 ms |
5524 KB |
Output is correct |
54 |
Correct |
374 ms |
5620 KB |
Output is correct |
55 |
Correct |
5 ms |
1628 KB |
Output is correct |
56 |
Correct |
6 ms |
1628 KB |
Output is correct |
57 |
Correct |
1 ms |
860 KB |
Output is correct |
58 |
Correct |
310 ms |
5484 KB |
Output is correct |
59 |
Correct |
10 ms |
2144 KB |
Output is correct |
60 |
Correct |
5 ms |
1628 KB |
Output is correct |
61 |
Correct |
10 ms |
2068 KB |
Output is correct |
62 |
Correct |
10 ms |
1884 KB |
Output is correct |
63 |
Correct |
68 ms |
3028 KB |
Output is correct |
64 |
Correct |
35 ms |
2652 KB |
Output is correct |
65 |
Correct |
9 ms |
1880 KB |
Output is correct |
66 |
Correct |
10 ms |
2024 KB |
Output is correct |
67 |
Correct |
48 ms |
3420 KB |
Output is correct |
68 |
Correct |
35 ms |
2648 KB |
Output is correct |
69 |
Correct |
8 ms |
1880 KB |
Output is correct |
70 |
Correct |
19 ms |
2652 KB |
Output is correct |
71 |
Correct |
48 ms |
3372 KB |
Output is correct |
72 |
Correct |
44 ms |
3412 KB |
Output is correct |
73 |
Correct |
5 ms |
1628 KB |
Output is correct |
74 |
Correct |
20 ms |
2708 KB |
Output is correct |
75 |
Correct |
37 ms |
3340 KB |
Output is correct |
76 |
Correct |
12 ms |
2396 KB |
Output is correct |
77 |
Correct |
71 ms |
3796 KB |
Output is correct |
78 |
Correct |
5 ms |
1624 KB |
Output is correct |
79 |
Correct |
35 ms |
2140 KB |
Output is correct |
80 |
Correct |
12 ms |
2392 KB |
Output is correct |
81 |
Correct |
71 ms |
3792 KB |
Output is correct |
82 |
Correct |
2 ms |
860 KB |
Output is correct |
83 |
Correct |
40 ms |
2068 KB |
Output is correct |
84 |
Correct |
33 ms |
3436 KB |
Output is correct |
85 |
Correct |
2 ms |
892 KB |
Output is correct |
86 |
Correct |
34 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
1624 KB |
Output is correct |
4 |
Correct |
5 ms |
1628 KB |
Output is correct |
5 |
Correct |
5 ms |
1748 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
5 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
5 ms |
1624 KB |
Output is correct |
12 |
Correct |
5 ms |
1700 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
1628 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
5 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
1528 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
1372 KB |
Output is correct |
21 |
Correct |
4 ms |
1552 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
6 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
6 ms |
1784 KB |
Output is correct |
26 |
Correct |
6 ms |
1628 KB |
Output is correct |
27 |
Correct |
5 ms |
1572 KB |
Output is correct |
28 |
Correct |
6 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
7 ms |
1628 KB |
Output is correct |
31 |
Correct |
7 ms |
1772 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
6 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1768 KB |
Output is correct |
35 |
Correct |
3 ms |
1112 KB |
Output is correct |
36 |
Correct |
3 ms |
1136 KB |
Output is correct |
37 |
Correct |
3 ms |
1112 KB |
Output is correct |
38 |
Correct |
2 ms |
860 KB |
Output is correct |
39 |
Correct |
2 ms |
860 KB |
Output is correct |
40 |
Correct |
10 ms |
2088 KB |
Output is correct |
41 |
Correct |
2 ms |
860 KB |
Output is correct |
42 |
Correct |
10 ms |
1884 KB |
Output is correct |
43 |
Correct |
9 ms |
2124 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
184 ms |
22328 KB |
Output is correct |
46 |
Correct |
77 ms |
15568 KB |
Output is correct |
47 |
Correct |
160 ms |
22476 KB |
Output is correct |
48 |
Correct |
157 ms |
22472 KB |
Output is correct |
49 |
Correct |
53 ms |
14208 KB |
Output is correct |
50 |
Correct |
185 ms |
28768 KB |
Output is correct |
51 |
Correct |
161 ms |
22428 KB |
Output is correct |
52 |
Correct |
57 ms |
13656 KB |
Output is correct |
53 |
Correct |
51 ms |
14180 KB |
Output is correct |
54 |
Correct |
11 ms |
4056 KB |
Output is correct |
55 |
Correct |
185 ms |
28876 KB |
Output is correct |
56 |
Correct |
37 ms |
11216 KB |
Output is correct |
57 |
Correct |
53 ms |
13516 KB |
Output is correct |
58 |
Correct |
79 ms |
15048 KB |
Output is correct |
59 |
Correct |
37 ms |
11212 KB |
Output is correct |
60 |
Correct |
37 ms |
11336 KB |
Output is correct |
61 |
Correct |
80 ms |
15016 KB |
Output is correct |
62 |
Correct |
55 ms |
13260 KB |
Output is correct |
63 |
Correct |
93 ms |
16336 KB |
Output is correct |
64 |
Correct |
36 ms |
11312 KB |
Output is correct |
65 |
Correct |
120 ms |
18388 KB |
Output is correct |
66 |
Correct |
55 ms |
13264 KB |
Output is correct |
67 |
Correct |
94 ms |
16560 KB |
Output is correct |
68 |
Correct |
114 ms |
17872 KB |
Output is correct |
69 |
Correct |
119 ms |
18388 KB |
Output is correct |
70 |
Correct |
55 ms |
13260 KB |
Output is correct |
71 |
Correct |
126 ms |
17876 KB |
Output is correct |
72 |
Correct |
88 ms |
16596 KB |
Output is correct |
73 |
Correct |
149 ms |
19640 KB |
Output is correct |
74 |
Correct |
54 ms |
13260 KB |
Output is correct |
75 |
Correct |
48 ms |
8836 KB |
Output is correct |
76 |
Correct |
88 ms |
16588 KB |
Output is correct |
77 |
Correct |
133 ms |
19556 KB |
Output is correct |
78 |
Correct |
63 ms |
9844 KB |
Output is correct |
79 |
Correct |
50 ms |
8656 KB |
Output is correct |
80 |
Correct |
22 ms |
4820 KB |
Output is correct |
81 |
Correct |
63 ms |
9868 KB |
Output is correct |
82 |
Correct |
104 ms |
17372 KB |
Output is correct |
83 |
Correct |
27 ms |
4948 KB |
Output is correct |
84 |
Correct |
103 ms |
17472 KB |
Output is correct |