#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, K;
cin >> N >> K;
vector<set<int>> graph(N);
set<pair<int, int>> nodes;
for (int node = 0; node < N; node++) {
int degree;
cin >> degree;
nodes.emplace(degree, node);
for (int j = 0; j < degree; j++) {
int neighbour;
cin >> neighbour;
graph[node].insert(neighbour);
}
}
vector<int> to(N, -1);
int answer = 0;
while (!nodes.empty()) {
auto [degree, node] = *nodes.begin();
nodes.erase({degree, node});
vector<int> neighbours;
to[node] = 0;
for (int i = 0; i < degree; i++) {
int neighbour = *graph[node].begin();
nodes.erase({(int)graph[neighbour].size(), neighbour});
graph[node].erase(neighbour);
graph[neighbour].erase(node);
nodes.emplace((int)graph[neighbour].size(), neighbour);
to[neighbour] = 1 + i;
neighbours.push_back(neighbour);
}
vector<int16_t> small_graph(degree + 1);
small_graph[to[node]] = (1 << (degree + 1)) - 1;
for (int x : neighbours) {
small_graph[to[x]] |= 1 << to[x];
small_graph[to[x]] |= 1 << to[node];
for (int y : graph[x]) {
if (to[y] != -1) {
small_graph[to[x]] |= 1 << to[y];
}
}
}
for (int clique = 0; clique < (1 << degree); clique++) {
int16_t intersection = small_graph[to[node]];
for (int vertex = 1; vertex < degree + 1; vertex++) {
if ((clique >> (vertex - 1)) & 1) {
intersection &= small_graph[vertex];
}
}
if (((clique << 1) | 1) == intersection) {
answer = max(answer, __builtin_popcount(intersection));
}
}
to[node] = -1;
for (int neighbour : neighbours) {
to[neighbour] = -1;
}
}
cout << answer << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
4 |
Correct |
87 ms |
1236 KB |
Output is correct |
5 |
Correct |
88 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
4 |
Correct |
87 ms |
1236 KB |
Output is correct |
5 |
Correct |
88 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
89 ms |
1236 KB |
Output is correct |
12 |
Correct |
85 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
87 ms |
1236 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
2 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
5 ms |
1364 KB |
Output is correct |
24 |
Correct |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
5 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
6 ms |
1236 KB |
Output is correct |
29 |
Correct |
5 ms |
1236 KB |
Output is correct |
30 |
Correct |
22 ms |
1364 KB |
Output is correct |
31 |
Correct |
5 ms |
1364 KB |
Output is correct |
32 |
Correct |
21 ms |
1364 KB |
Output is correct |
33 |
Correct |
5 ms |
1364 KB |
Output is correct |
34 |
Correct |
5 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
876 KB |
Output is correct |
36 |
Correct |
3 ms |
872 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
8 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
8 ms |
1748 KB |
Output is correct |
43 |
Correct |
8 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
317 ms |
26404 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
313 ms |
26252 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
313 ms |
26276 KB |
Output is correct |
16 |
Correct |
303 ms |
26336 KB |
Output is correct |
17 |
Correct |
303 ms |
26312 KB |
Output is correct |
18 |
Correct |
309 ms |
26212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
4 |
Correct |
87 ms |
1236 KB |
Output is correct |
5 |
Correct |
88 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
89 ms |
1236 KB |
Output is correct |
12 |
Correct |
85 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
87 ms |
1236 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
2 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
5 ms |
1364 KB |
Output is correct |
24 |
Correct |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
5 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
6 ms |
1236 KB |
Output is correct |
29 |
Correct |
5 ms |
1236 KB |
Output is correct |
30 |
Correct |
22 ms |
1364 KB |
Output is correct |
31 |
Correct |
5 ms |
1364 KB |
Output is correct |
32 |
Correct |
21 ms |
1364 KB |
Output is correct |
33 |
Correct |
5 ms |
1364 KB |
Output is correct |
34 |
Correct |
5 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
876 KB |
Output is correct |
36 |
Correct |
3 ms |
872 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
8 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
8 ms |
1748 KB |
Output is correct |
43 |
Correct |
8 ms |
1748 KB |
Output is correct |
44 |
Correct |
15 ms |
2644 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
8 ms |
1748 KB |
Output is correct |
47 |
Correct |
17 ms |
2772 KB |
Output is correct |
48 |
Correct |
8 ms |
1748 KB |
Output is correct |
49 |
Correct |
17 ms |
2892 KB |
Output is correct |
50 |
Correct |
17 ms |
2772 KB |
Output is correct |
51 |
Correct |
54 ms |
4948 KB |
Output is correct |
52 |
Correct |
86 ms |
1228 KB |
Output is correct |
53 |
Correct |
1322 ms |
5356 KB |
Output is correct |
54 |
Correct |
79 ms |
5460 KB |
Output is correct |
55 |
Correct |
5 ms |
1228 KB |
Output is correct |
56 |
Correct |
89 ms |
1236 KB |
Output is correct |
57 |
Correct |
1 ms |
724 KB |
Output is correct |
58 |
Correct |
1347 ms |
5432 KB |
Output is correct |
59 |
Correct |
6 ms |
1748 KB |
Output is correct |
60 |
Correct |
5 ms |
1240 KB |
Output is correct |
61 |
Correct |
6 ms |
1740 KB |
Output is correct |
62 |
Correct |
6 ms |
1772 KB |
Output is correct |
63 |
Correct |
15 ms |
2892 KB |
Output is correct |
64 |
Correct |
13 ms |
2516 KB |
Output is correct |
65 |
Correct |
7 ms |
1612 KB |
Output is correct |
66 |
Correct |
6 ms |
1748 KB |
Output is correct |
67 |
Correct |
22 ms |
3284 KB |
Output is correct |
68 |
Correct |
12 ms |
2516 KB |
Output is correct |
69 |
Correct |
7 ms |
1620 KB |
Output is correct |
70 |
Correct |
15 ms |
2644 KB |
Output is correct |
71 |
Correct |
21 ms |
3280 KB |
Output is correct |
72 |
Correct |
20 ms |
3192 KB |
Output is correct |
73 |
Correct |
4 ms |
1236 KB |
Output is correct |
74 |
Correct |
15 ms |
2644 KB |
Output is correct |
75 |
Correct |
21 ms |
3156 KB |
Output is correct |
76 |
Correct |
27 ms |
2132 KB |
Output is correct |
77 |
Correct |
29 ms |
3796 KB |
Output is correct |
78 |
Correct |
4 ms |
1236 KB |
Output is correct |
79 |
Correct |
14 ms |
2048 KB |
Output is correct |
80 |
Correct |
27 ms |
2120 KB |
Output is correct |
81 |
Correct |
33 ms |
3704 KB |
Output is correct |
82 |
Correct |
2 ms |
588 KB |
Output is correct |
83 |
Correct |
15 ms |
2048 KB |
Output is correct |
84 |
Correct |
19 ms |
3156 KB |
Output is correct |
85 |
Correct |
3 ms |
596 KB |
Output is correct |
86 |
Correct |
19 ms |
3068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
4 |
Correct |
87 ms |
1236 KB |
Output is correct |
5 |
Correct |
88 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1236 KB |
Output is correct |
7 |
Correct |
5 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
89 ms |
1236 KB |
Output is correct |
12 |
Correct |
85 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
87 ms |
1236 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
1236 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
2 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
5 ms |
1364 KB |
Output is correct |
24 |
Correct |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
5 ms |
1364 KB |
Output is correct |
26 |
Correct |
5 ms |
1236 KB |
Output is correct |
27 |
Correct |
4 ms |
1236 KB |
Output is correct |
28 |
Correct |
6 ms |
1236 KB |
Output is correct |
29 |
Correct |
5 ms |
1236 KB |
Output is correct |
30 |
Correct |
22 ms |
1364 KB |
Output is correct |
31 |
Correct |
5 ms |
1364 KB |
Output is correct |
32 |
Correct |
21 ms |
1364 KB |
Output is correct |
33 |
Correct |
5 ms |
1364 KB |
Output is correct |
34 |
Correct |
5 ms |
1364 KB |
Output is correct |
35 |
Correct |
3 ms |
876 KB |
Output is correct |
36 |
Correct |
3 ms |
872 KB |
Output is correct |
37 |
Correct |
3 ms |
852 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
8 ms |
1748 KB |
Output is correct |
41 |
Correct |
2 ms |
596 KB |
Output is correct |
42 |
Correct |
8 ms |
1748 KB |
Output is correct |
43 |
Correct |
8 ms |
1748 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
179 ms |
19288 KB |
Output is correct |
46 |
Execution timed out |
3063 ms |
13140 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |