#pragma GCC optmize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int MAXN = 5e4 + 10;
deque<int> adj[MAXN];
void merge(deque<int>& v1, deque<int>& v2, deque<int>& res) {
int n = v1.size(), m = v2.size();
int p1 = 0, p2 = 0;
while ((p1 < n) && (p2 < m)) {
if (v1[p1] == v2[p2]) {
res.push_back(v1[p1]);
p1++;
p2++;
continue;
}
if (v1[p1] < v2[p2]) p1++;
else p2++;
}
}
int best(deque<int> pos) {
int mx = 0;
while (!pos.empty()) {
auto u = pos.front();
pos.pop_front();
deque<int> nxt;
merge(pos, adj[u], nxt);
mx = max(mx, 1 + best(nxt));
}
return mx;
}
int32_t main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
while (x--) {
int v;
cin >> v;
adj[i].push_back(v);
}
sort(adj[i].begin(), adj[i].end());
}
int ans = 0;
for (int i = 0; i < n; i++) {
ans = max(ans, best(adj[i]) + 1);
}
cout << ans << "\n";
}
Compilation message
politicaldevelopment.cpp:1: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
1 | #pragma GCC optmize("O3")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
33872 KB |
Output is correct |
2 |
Correct |
20 ms |
33980 KB |
Output is correct |
3 |
Correct |
24 ms |
34128 KB |
Output is correct |
4 |
Correct |
29 ms |
34128 KB |
Output is correct |
5 |
Correct |
32 ms |
34140 KB |
Output is correct |
6 |
Correct |
31 ms |
33884 KB |
Output is correct |
7 |
Correct |
27 ms |
33872 KB |
Output is correct |
8 |
Correct |
26 ms |
33872 KB |
Output is correct |
9 |
Correct |
24 ms |
33872 KB |
Output is correct |
10 |
Correct |
23 ms |
34128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
33872 KB |
Output is correct |
2 |
Correct |
20 ms |
33980 KB |
Output is correct |
3 |
Correct |
24 ms |
34128 KB |
Output is correct |
4 |
Correct |
29 ms |
34128 KB |
Output is correct |
5 |
Correct |
32 ms |
34140 KB |
Output is correct |
6 |
Correct |
31 ms |
33884 KB |
Output is correct |
7 |
Correct |
27 ms |
33872 KB |
Output is correct |
8 |
Correct |
26 ms |
33872 KB |
Output is correct |
9 |
Correct |
24 ms |
33872 KB |
Output is correct |
10 |
Correct |
23 ms |
34128 KB |
Output is correct |
11 |
Correct |
29 ms |
33968 KB |
Output is correct |
12 |
Correct |
29 ms |
34128 KB |
Output is correct |
13 |
Correct |
21 ms |
33876 KB |
Output is correct |
14 |
Correct |
42 ms |
34076 KB |
Output is correct |
15 |
Correct |
22 ms |
33872 KB |
Output is correct |
16 |
Correct |
27 ms |
33872 KB |
Output is correct |
17 |
Correct |
22 ms |
33872 KB |
Output is correct |
18 |
Correct |
31 ms |
33872 KB |
Output is correct |
19 |
Correct |
25 ms |
33872 KB |
Output is correct |
20 |
Correct |
27 ms |
33868 KB |
Output is correct |
21 |
Correct |
26 ms |
33872 KB |
Output is correct |
22 |
Correct |
24 ms |
33872 KB |
Output is correct |
23 |
Correct |
27 ms |
33884 KB |
Output is correct |
24 |
Correct |
24 ms |
33872 KB |
Output is correct |
25 |
Correct |
26 ms |
33872 KB |
Output is correct |
26 |
Correct |
28 ms |
34128 KB |
Output is correct |
27 |
Correct |
31 ms |
33872 KB |
Output is correct |
28 |
Correct |
29 ms |
33872 KB |
Output is correct |
29 |
Correct |
27 ms |
33872 KB |
Output is correct |
30 |
Correct |
40 ms |
33872 KB |
Output is correct |
31 |
Correct |
27 ms |
33932 KB |
Output is correct |
32 |
Correct |
41 ms |
33864 KB |
Output is correct |
33 |
Correct |
34 ms |
34072 KB |
Output is correct |
34 |
Correct |
26 ms |
33872 KB |
Output is correct |
35 |
Correct |
26 ms |
33872 KB |
Output is correct |
36 |
Correct |
26 ms |
34008 KB |
Output is correct |
37 |
Correct |
29 ms |
33872 KB |
Output is correct |
38 |
Correct |
29 ms |
33972 KB |
Output is correct |
39 |
Correct |
25 ms |
34128 KB |
Output is correct |
40 |
Correct |
31 ms |
34040 KB |
Output is correct |
41 |
Correct |
24 ms |
34232 KB |
Output is correct |
42 |
Correct |
31 ms |
33864 KB |
Output is correct |
43 |
Correct |
29 ms |
33872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
33872 KB |
Output is correct |
2 |
Correct |
23 ms |
34068 KB |
Output is correct |
3 |
Correct |
25 ms |
33872 KB |
Output is correct |
4 |
Correct |
25 ms |
33872 KB |
Output is correct |
5 |
Correct |
26 ms |
33860 KB |
Output is correct |
6 |
Correct |
24 ms |
33884 KB |
Output is correct |
7 |
Correct |
23 ms |
34040 KB |
Output is correct |
8 |
Correct |
23 ms |
33872 KB |
Output is correct |
9 |
Correct |
25 ms |
33872 KB |
Output is correct |
10 |
Correct |
25 ms |
33872 KB |
Output is correct |
11 |
Correct |
198 ms |
33872 KB |
Output is correct |
12 |
Correct |
24 ms |
33872 KB |
Output is correct |
13 |
Correct |
185 ms |
33872 KB |
Output is correct |
14 |
Correct |
22 ms |
33984 KB |
Output is correct |
15 |
Correct |
186 ms |
33864 KB |
Output is correct |
16 |
Correct |
208 ms |
33892 KB |
Output is correct |
17 |
Correct |
188 ms |
33872 KB |
Output is correct |
18 |
Correct |
199 ms |
35604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
33872 KB |
Output is correct |
2 |
Correct |
20 ms |
33980 KB |
Output is correct |
3 |
Correct |
24 ms |
34128 KB |
Output is correct |
4 |
Correct |
29 ms |
34128 KB |
Output is correct |
5 |
Correct |
32 ms |
34140 KB |
Output is correct |
6 |
Correct |
31 ms |
33884 KB |
Output is correct |
7 |
Correct |
27 ms |
33872 KB |
Output is correct |
8 |
Correct |
26 ms |
33872 KB |
Output is correct |
9 |
Correct |
24 ms |
33872 KB |
Output is correct |
10 |
Correct |
23 ms |
34128 KB |
Output is correct |
11 |
Correct |
29 ms |
33968 KB |
Output is correct |
12 |
Correct |
29 ms |
34128 KB |
Output is correct |
13 |
Correct |
21 ms |
33876 KB |
Output is correct |
14 |
Correct |
42 ms |
34076 KB |
Output is correct |
15 |
Correct |
22 ms |
33872 KB |
Output is correct |
16 |
Correct |
27 ms |
33872 KB |
Output is correct |
17 |
Correct |
22 ms |
33872 KB |
Output is correct |
18 |
Correct |
31 ms |
33872 KB |
Output is correct |
19 |
Correct |
25 ms |
33872 KB |
Output is correct |
20 |
Correct |
27 ms |
33868 KB |
Output is correct |
21 |
Correct |
26 ms |
33872 KB |
Output is correct |
22 |
Correct |
24 ms |
33872 KB |
Output is correct |
23 |
Correct |
27 ms |
33884 KB |
Output is correct |
24 |
Correct |
24 ms |
33872 KB |
Output is correct |
25 |
Correct |
26 ms |
33872 KB |
Output is correct |
26 |
Correct |
28 ms |
34128 KB |
Output is correct |
27 |
Correct |
31 ms |
33872 KB |
Output is correct |
28 |
Correct |
29 ms |
33872 KB |
Output is correct |
29 |
Correct |
27 ms |
33872 KB |
Output is correct |
30 |
Correct |
40 ms |
33872 KB |
Output is correct |
31 |
Correct |
27 ms |
33932 KB |
Output is correct |
32 |
Correct |
41 ms |
33864 KB |
Output is correct |
33 |
Correct |
34 ms |
34072 KB |
Output is correct |
34 |
Correct |
26 ms |
33872 KB |
Output is correct |
35 |
Correct |
26 ms |
33872 KB |
Output is correct |
36 |
Correct |
26 ms |
34008 KB |
Output is correct |
37 |
Correct |
29 ms |
33872 KB |
Output is correct |
38 |
Correct |
29 ms |
33972 KB |
Output is correct |
39 |
Correct |
25 ms |
34128 KB |
Output is correct |
40 |
Correct |
31 ms |
34040 KB |
Output is correct |
41 |
Correct |
24 ms |
34232 KB |
Output is correct |
42 |
Correct |
31 ms |
33864 KB |
Output is correct |
43 |
Correct |
29 ms |
33872 KB |
Output is correct |
44 |
Correct |
154 ms |
33872 KB |
Output is correct |
45 |
Correct |
22 ms |
33872 KB |
Output is correct |
46 |
Correct |
28 ms |
34116 KB |
Output is correct |
47 |
Correct |
34 ms |
34100 KB |
Output is correct |
48 |
Correct |
28 ms |
33884 KB |
Output is correct |
49 |
Correct |
35 ms |
33872 KB |
Output is correct |
50 |
Correct |
35 ms |
33872 KB |
Output is correct |
51 |
Correct |
55 ms |
33956 KB |
Output is correct |
52 |
Correct |
25 ms |
34112 KB |
Output is correct |
53 |
Correct |
1254 ms |
34292 KB |
Output is correct |
54 |
Correct |
71 ms |
33872 KB |
Output is correct |
55 |
Correct |
27 ms |
33864 KB |
Output is correct |
56 |
Correct |
26 ms |
34128 KB |
Output is correct |
57 |
Correct |
25 ms |
33872 KB |
Output is correct |
58 |
Correct |
1048 ms |
34288 KB |
Output is correct |
59 |
Correct |
36 ms |
33864 KB |
Output is correct |
60 |
Correct |
31 ms |
33872 KB |
Output is correct |
61 |
Correct |
35 ms |
34124 KB |
Output is correct |
62 |
Correct |
36 ms |
33872 KB |
Output is correct |
63 |
Correct |
153 ms |
33872 KB |
Output is correct |
64 |
Correct |
99 ms |
33864 KB |
Output is correct |
65 |
Correct |
30 ms |
34092 KB |
Output is correct |
66 |
Correct |
36 ms |
33872 KB |
Output is correct |
67 |
Correct |
83 ms |
34092 KB |
Output is correct |
68 |
Correct |
91 ms |
33872 KB |
Output is correct |
69 |
Correct |
30 ms |
33872 KB |
Output is correct |
70 |
Correct |
39 ms |
33872 KB |
Output is correct |
71 |
Correct |
73 ms |
33872 KB |
Output is correct |
72 |
Correct |
57 ms |
33868 KB |
Output is correct |
73 |
Correct |
27 ms |
33872 KB |
Output is correct |
74 |
Correct |
41 ms |
33872 KB |
Output is correct |
75 |
Correct |
60 ms |
33872 KB |
Output is correct |
76 |
Correct |
47 ms |
33864 KB |
Output is correct |
77 |
Correct |
45 ms |
33872 KB |
Output is correct |
78 |
Correct |
28 ms |
33944 KB |
Output is correct |
79 |
Correct |
33 ms |
33872 KB |
Output is correct |
80 |
Correct |
55 ms |
34112 KB |
Output is correct |
81 |
Correct |
49 ms |
33884 KB |
Output is correct |
82 |
Correct |
30 ms |
33864 KB |
Output is correct |
83 |
Correct |
38 ms |
33888 KB |
Output is correct |
84 |
Correct |
38 ms |
33884 KB |
Output is correct |
85 |
Correct |
27 ms |
33952 KB |
Output is correct |
86 |
Correct |
41 ms |
33872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
33872 KB |
Output is correct |
2 |
Correct |
20 ms |
33980 KB |
Output is correct |
3 |
Correct |
24 ms |
34128 KB |
Output is correct |
4 |
Correct |
29 ms |
34128 KB |
Output is correct |
5 |
Correct |
32 ms |
34140 KB |
Output is correct |
6 |
Correct |
31 ms |
33884 KB |
Output is correct |
7 |
Correct |
27 ms |
33872 KB |
Output is correct |
8 |
Correct |
26 ms |
33872 KB |
Output is correct |
9 |
Correct |
24 ms |
33872 KB |
Output is correct |
10 |
Correct |
23 ms |
34128 KB |
Output is correct |
11 |
Correct |
29 ms |
33968 KB |
Output is correct |
12 |
Correct |
29 ms |
34128 KB |
Output is correct |
13 |
Correct |
21 ms |
33876 KB |
Output is correct |
14 |
Correct |
42 ms |
34076 KB |
Output is correct |
15 |
Correct |
22 ms |
33872 KB |
Output is correct |
16 |
Correct |
27 ms |
33872 KB |
Output is correct |
17 |
Correct |
22 ms |
33872 KB |
Output is correct |
18 |
Correct |
31 ms |
33872 KB |
Output is correct |
19 |
Correct |
25 ms |
33872 KB |
Output is correct |
20 |
Correct |
27 ms |
33868 KB |
Output is correct |
21 |
Correct |
26 ms |
33872 KB |
Output is correct |
22 |
Correct |
24 ms |
33872 KB |
Output is correct |
23 |
Correct |
27 ms |
33884 KB |
Output is correct |
24 |
Correct |
24 ms |
33872 KB |
Output is correct |
25 |
Correct |
26 ms |
33872 KB |
Output is correct |
26 |
Correct |
28 ms |
34128 KB |
Output is correct |
27 |
Correct |
31 ms |
33872 KB |
Output is correct |
28 |
Correct |
29 ms |
33872 KB |
Output is correct |
29 |
Correct |
27 ms |
33872 KB |
Output is correct |
30 |
Correct |
40 ms |
33872 KB |
Output is correct |
31 |
Correct |
27 ms |
33932 KB |
Output is correct |
32 |
Correct |
41 ms |
33864 KB |
Output is correct |
33 |
Correct |
34 ms |
34072 KB |
Output is correct |
34 |
Correct |
26 ms |
33872 KB |
Output is correct |
35 |
Correct |
26 ms |
33872 KB |
Output is correct |
36 |
Correct |
26 ms |
34008 KB |
Output is correct |
37 |
Correct |
29 ms |
33872 KB |
Output is correct |
38 |
Correct |
29 ms |
33972 KB |
Output is correct |
39 |
Correct |
25 ms |
34128 KB |
Output is correct |
40 |
Correct |
31 ms |
34040 KB |
Output is correct |
41 |
Correct |
24 ms |
34232 KB |
Output is correct |
42 |
Correct |
31 ms |
33864 KB |
Output is correct |
43 |
Correct |
29 ms |
33872 KB |
Output is correct |
44 |
Correct |
25 ms |
33876 KB |
Output is correct |
45 |
Correct |
138 ms |
34088 KB |
Output is correct |
46 |
Correct |
1871 ms |
34296 KB |
Output is correct |
47 |
Correct |
161 ms |
34104 KB |
Output is correct |
48 |
Correct |
147 ms |
34120 KB |
Output is correct |
49 |
Correct |
1982 ms |
34504 KB |
Output is correct |
50 |
Execution timed out |
3065 ms |
34888 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |