#include <bits/stdc++.h>
using namespace std;
int deg[50005];
vector<int> adj[50005];
set<pair<int, int>> s;
vector<int> neighbours;
bool erased[50005];
int ans = 0;
int sz;
bool check(int mask) {
for (int i = 0; i < sz; i++) {
if ((1 << i) & mask) {
for (int j = 0; j < i; j++) {
if (( 1 << j ) & mask) {
int a = neighbours[i], b = neighbours[j];
if (*lower_bound(adj[a].begin(), adj[a].end(), b) != b) return false;
}
}
}
}
return true;
}
int main() {
int n, k; cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> deg[i];
s.insert({deg[i], i});
for (int _ = 0; _ < deg[i]; _++) {
int to; cin >> to;
adj[i].push_back(to);
}
sort(adj[i].begin(), adj[i].end());
}
for (int i = 0; i < n; i++) {
auto cur = *s.begin();
s.erase(s.begin()); erased[cur.second] = true;
neighbours.clear();
neighbours.push_back(cur.second);
for (auto nxt : adj[cur.second]) {
if (erased[nxt]) continue;
neighbours.push_back(nxt);
}
sz = neighbours.size();
for (int mask = (1 << sz) - 1; mask >= (1 << ans); mask--) {
if (__builtin_popcount(mask) <= ans) continue;
if (check(mask)) ans = __builtin_popcount(mask);
}
for (auto nxt : adj[cur.second]) {
if (erased[nxt]) continue;
s.erase({deg[nxt], nxt}); deg[nxt]--;
s.insert({deg[nxt], nxt});
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
8 ms |
1876 KB |
Output is correct |
4 |
Correct |
8 ms |
1860 KB |
Output is correct |
5 |
Correct |
6 ms |
1876 KB |
Output is correct |
6 |
Correct |
7 ms |
1876 KB |
Output is correct |
7 |
Correct |
7 ms |
1876 KB |
Output is correct |
8 |
Correct |
3 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
8 ms |
1876 KB |
Output is correct |
4 |
Correct |
8 ms |
1860 KB |
Output is correct |
5 |
Correct |
6 ms |
1876 KB |
Output is correct |
6 |
Correct |
7 ms |
1876 KB |
Output is correct |
7 |
Correct |
7 ms |
1876 KB |
Output is correct |
8 |
Correct |
3 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
11 |
Correct |
6 ms |
1876 KB |
Output is correct |
12 |
Correct |
6 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1480 KB |
Output is correct |
16 |
Correct |
7 ms |
1908 KB |
Output is correct |
17 |
Correct |
1 ms |
1364 KB |
Output is correct |
18 |
Correct |
8 ms |
1876 KB |
Output is correct |
19 |
Correct |
3 ms |
1744 KB |
Output is correct |
20 |
Correct |
5 ms |
1876 KB |
Output is correct |
21 |
Correct |
5 ms |
1880 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
8 ms |
1876 KB |
Output is correct |
24 |
Correct |
3 ms |
1748 KB |
Output is correct |
25 |
Correct |
9 ms |
1876 KB |
Output is correct |
26 |
Correct |
8 ms |
1876 KB |
Output is correct |
27 |
Correct |
9 ms |
1956 KB |
Output is correct |
28 |
Correct |
8 ms |
1876 KB |
Output is correct |
29 |
Correct |
7 ms |
1876 KB |
Output is correct |
30 |
Correct |
9 ms |
1876 KB |
Output is correct |
31 |
Correct |
11 ms |
2100 KB |
Output is correct |
32 |
Correct |
9 ms |
1876 KB |
Output is correct |
33 |
Correct |
9 ms |
1880 KB |
Output is correct |
34 |
Correct |
9 ms |
1876 KB |
Output is correct |
35 |
Correct |
5 ms |
1620 KB |
Output is correct |
36 |
Correct |
5 ms |
1628 KB |
Output is correct |
37 |
Correct |
5 ms |
1620 KB |
Output is correct |
38 |
Correct |
4 ms |
1624 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
12 ms |
2008 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
13 ms |
2032 KB |
Output is correct |
43 |
Correct |
15 ms |
2004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1488 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
472 ms |
10628 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
462 ms |
10560 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
407 ms |
10516 KB |
Output is correct |
16 |
Correct |
451 ms |
10572 KB |
Output is correct |
17 |
Correct |
458 ms |
10712 KB |
Output is correct |
18 |
Correct |
404 ms |
10592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
8 ms |
1876 KB |
Output is correct |
4 |
Correct |
8 ms |
1860 KB |
Output is correct |
5 |
Correct |
6 ms |
1876 KB |
Output is correct |
6 |
Correct |
7 ms |
1876 KB |
Output is correct |
7 |
Correct |
7 ms |
1876 KB |
Output is correct |
8 |
Correct |
3 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
11 |
Correct |
6 ms |
1876 KB |
Output is correct |
12 |
Correct |
6 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1480 KB |
Output is correct |
16 |
Correct |
7 ms |
1908 KB |
Output is correct |
17 |
Correct |
1 ms |
1364 KB |
Output is correct |
18 |
Correct |
8 ms |
1876 KB |
Output is correct |
19 |
Correct |
3 ms |
1744 KB |
Output is correct |
20 |
Correct |
5 ms |
1876 KB |
Output is correct |
21 |
Correct |
5 ms |
1880 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
8 ms |
1876 KB |
Output is correct |
24 |
Correct |
3 ms |
1748 KB |
Output is correct |
25 |
Correct |
9 ms |
1876 KB |
Output is correct |
26 |
Correct |
8 ms |
1876 KB |
Output is correct |
27 |
Correct |
9 ms |
1956 KB |
Output is correct |
28 |
Correct |
8 ms |
1876 KB |
Output is correct |
29 |
Correct |
7 ms |
1876 KB |
Output is correct |
30 |
Correct |
9 ms |
1876 KB |
Output is correct |
31 |
Correct |
11 ms |
2100 KB |
Output is correct |
32 |
Correct |
9 ms |
1876 KB |
Output is correct |
33 |
Correct |
9 ms |
1880 KB |
Output is correct |
34 |
Correct |
9 ms |
1876 KB |
Output is correct |
35 |
Correct |
5 ms |
1620 KB |
Output is correct |
36 |
Correct |
5 ms |
1628 KB |
Output is correct |
37 |
Correct |
5 ms |
1620 KB |
Output is correct |
38 |
Correct |
4 ms |
1624 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
12 ms |
2008 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
13 ms |
2032 KB |
Output is correct |
43 |
Correct |
15 ms |
2004 KB |
Output is correct |
44 |
Correct |
20 ms |
2136 KB |
Output is correct |
45 |
Correct |
1 ms |
1364 KB |
Output is correct |
46 |
Correct |
13 ms |
2008 KB |
Output is correct |
47 |
Correct |
25 ms |
2212 KB |
Output is correct |
48 |
Correct |
12 ms |
1940 KB |
Output is correct |
49 |
Correct |
27 ms |
2124 KB |
Output is correct |
50 |
Correct |
24 ms |
2212 KB |
Output is correct |
51 |
Correct |
136 ms |
2620 KB |
Output is correct |
52 |
Correct |
6 ms |
1876 KB |
Output is correct |
53 |
Correct |
295 ms |
2752 KB |
Output is correct |
54 |
Correct |
240 ms |
2676 KB |
Output is correct |
55 |
Correct |
7 ms |
1876 KB |
Output is correct |
56 |
Correct |
6 ms |
1948 KB |
Output is correct |
57 |
Correct |
3 ms |
1752 KB |
Output is correct |
58 |
Correct |
309 ms |
2748 KB |
Output is correct |
59 |
Correct |
10 ms |
2000 KB |
Output is correct |
60 |
Correct |
7 ms |
1876 KB |
Output is correct |
61 |
Correct |
12 ms |
2004 KB |
Output is correct |
62 |
Correct |
10 ms |
1876 KB |
Output is correct |
63 |
Correct |
16 ms |
2080 KB |
Output is correct |
64 |
Correct |
15 ms |
2132 KB |
Output is correct |
65 |
Correct |
11 ms |
2004 KB |
Output is correct |
66 |
Correct |
12 ms |
1880 KB |
Output is correct |
67 |
Correct |
33 ms |
2280 KB |
Output is correct |
68 |
Correct |
15 ms |
2104 KB |
Output is correct |
69 |
Correct |
12 ms |
1924 KB |
Output is correct |
70 |
Correct |
23 ms |
2196 KB |
Output is correct |
71 |
Correct |
33 ms |
2288 KB |
Output is correct |
72 |
Correct |
29 ms |
2268 KB |
Output is correct |
73 |
Correct |
6 ms |
1884 KB |
Output is correct |
74 |
Correct |
20 ms |
2132 KB |
Output is correct |
75 |
Correct |
31 ms |
2284 KB |
Output is correct |
76 |
Correct |
16 ms |
2008 KB |
Output is correct |
77 |
Correct |
78 ms |
2408 KB |
Output is correct |
78 |
Correct |
8 ms |
1956 KB |
Output is correct |
79 |
Correct |
35 ms |
1876 KB |
Output is correct |
80 |
Correct |
14 ms |
2008 KB |
Output is correct |
81 |
Correct |
73 ms |
2408 KB |
Output is correct |
82 |
Correct |
4 ms |
1620 KB |
Output is correct |
83 |
Correct |
37 ms |
1940 KB |
Output is correct |
84 |
Correct |
39 ms |
2328 KB |
Output is correct |
85 |
Correct |
5 ms |
1620 KB |
Output is correct |
86 |
Correct |
23 ms |
2352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Correct |
8 ms |
1876 KB |
Output is correct |
4 |
Correct |
8 ms |
1860 KB |
Output is correct |
5 |
Correct |
6 ms |
1876 KB |
Output is correct |
6 |
Correct |
7 ms |
1876 KB |
Output is correct |
7 |
Correct |
7 ms |
1876 KB |
Output is correct |
8 |
Correct |
3 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
11 |
Correct |
6 ms |
1876 KB |
Output is correct |
12 |
Correct |
6 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1480 KB |
Output is correct |
16 |
Correct |
7 ms |
1908 KB |
Output is correct |
17 |
Correct |
1 ms |
1364 KB |
Output is correct |
18 |
Correct |
8 ms |
1876 KB |
Output is correct |
19 |
Correct |
3 ms |
1744 KB |
Output is correct |
20 |
Correct |
5 ms |
1876 KB |
Output is correct |
21 |
Correct |
5 ms |
1880 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
8 ms |
1876 KB |
Output is correct |
24 |
Correct |
3 ms |
1748 KB |
Output is correct |
25 |
Correct |
9 ms |
1876 KB |
Output is correct |
26 |
Correct |
8 ms |
1876 KB |
Output is correct |
27 |
Correct |
9 ms |
1956 KB |
Output is correct |
28 |
Correct |
8 ms |
1876 KB |
Output is correct |
29 |
Correct |
7 ms |
1876 KB |
Output is correct |
30 |
Correct |
9 ms |
1876 KB |
Output is correct |
31 |
Correct |
11 ms |
2100 KB |
Output is correct |
32 |
Correct |
9 ms |
1876 KB |
Output is correct |
33 |
Correct |
9 ms |
1880 KB |
Output is correct |
34 |
Correct |
9 ms |
1876 KB |
Output is correct |
35 |
Correct |
5 ms |
1620 KB |
Output is correct |
36 |
Correct |
5 ms |
1628 KB |
Output is correct |
37 |
Correct |
5 ms |
1620 KB |
Output is correct |
38 |
Correct |
4 ms |
1624 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
12 ms |
2008 KB |
Output is correct |
41 |
Correct |
3 ms |
1620 KB |
Output is correct |
42 |
Correct |
13 ms |
2032 KB |
Output is correct |
43 |
Correct |
15 ms |
2004 KB |
Output is correct |
44 |
Correct |
1 ms |
1364 KB |
Output is correct |
45 |
Correct |
215 ms |
8176 KB |
Output is correct |
46 |
Correct |
99 ms |
6548 KB |
Output is correct |
47 |
Correct |
232 ms |
8208 KB |
Output is correct |
48 |
Correct |
237 ms |
8260 KB |
Output is correct |
49 |
Correct |
64 ms |
6480 KB |
Output is correct |
50 |
Correct |
257 ms |
8904 KB |
Output is correct |
51 |
Correct |
221 ms |
8200 KB |
Output is correct |
52 |
Correct |
63 ms |
6452 KB |
Output is correct |
53 |
Correct |
69 ms |
6416 KB |
Output is correct |
54 |
Correct |
20 ms |
4132 KB |
Output is correct |
55 |
Correct |
266 ms |
8976 KB |
Output is correct |
56 |
Correct |
43 ms |
5964 KB |
Output is correct |
57 |
Correct |
65 ms |
6476 KB |
Output is correct |
58 |
Correct |
87 ms |
6460 KB |
Output is correct |
59 |
Correct |
45 ms |
5952 KB |
Output is correct |
60 |
Correct |
45 ms |
5964 KB |
Output is correct |
61 |
Correct |
86 ms |
6524 KB |
Output is correct |
62 |
Correct |
64 ms |
6208 KB |
Output is correct |
63 |
Correct |
126 ms |
6860 KB |
Output is correct |
64 |
Correct |
45 ms |
5976 KB |
Output is correct |
65 |
Correct |
161 ms |
7396 KB |
Output is correct |
66 |
Correct |
68 ms |
6220 KB |
Output is correct |
67 |
Correct |
119 ms |
6840 KB |
Output is correct |
68 |
Correct |
156 ms |
7264 KB |
Output is correct |
69 |
Correct |
160 ms |
7292 KB |
Output is correct |
70 |
Correct |
69 ms |
6212 KB |
Output is correct |
71 |
Correct |
152 ms |
7344 KB |
Output is correct |
72 |
Correct |
103 ms |
6816 KB |
Output is correct |
73 |
Correct |
179 ms |
7644 KB |
Output is correct |
74 |
Correct |
70 ms |
6220 KB |
Output is correct |
75 |
Correct |
71 ms |
4172 KB |
Output is correct |
76 |
Correct |
121 ms |
6896 KB |
Output is correct |
77 |
Correct |
176 ms |
7576 KB |
Output is correct |
78 |
Correct |
92 ms |
4548 KB |
Output is correct |
79 |
Correct |
65 ms |
4128 KB |
Output is correct |
80 |
Correct |
28 ms |
2868 KB |
Output is correct |
81 |
Correct |
91 ms |
4540 KB |
Output is correct |
82 |
Correct |
138 ms |
6804 KB |
Output is correct |
83 |
Correct |
28 ms |
2880 KB |
Output is correct |
84 |
Correct |
125 ms |
6844 KB |
Output is correct |