#pragma GCC optmize("Ofast")
#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("Ofast")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
33864 KB |
Output is correct |
2 |
Correct |
21 ms |
33872 KB |
Output is correct |
3 |
Correct |
25 ms |
34000 KB |
Output is correct |
4 |
Correct |
29 ms |
34140 KB |
Output is correct |
5 |
Correct |
33 ms |
34128 KB |
Output is correct |
6 |
Correct |
27 ms |
33864 KB |
Output is correct |
7 |
Correct |
26 ms |
33888 KB |
Output is correct |
8 |
Correct |
24 ms |
33872 KB |
Output is correct |
9 |
Correct |
31 ms |
33872 KB |
Output is correct |
10 |
Correct |
27 ms |
33872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
33864 KB |
Output is correct |
2 |
Correct |
21 ms |
33872 KB |
Output is correct |
3 |
Correct |
25 ms |
34000 KB |
Output is correct |
4 |
Correct |
29 ms |
34140 KB |
Output is correct |
5 |
Correct |
33 ms |
34128 KB |
Output is correct |
6 |
Correct |
27 ms |
33864 KB |
Output is correct |
7 |
Correct |
26 ms |
33888 KB |
Output is correct |
8 |
Correct |
24 ms |
33872 KB |
Output is correct |
9 |
Correct |
31 ms |
33872 KB |
Output is correct |
10 |
Correct |
27 ms |
33872 KB |
Output is correct |
11 |
Correct |
34 ms |
34128 KB |
Output is correct |
12 |
Correct |
31 ms |
34128 KB |
Output is correct |
13 |
Correct |
25 ms |
34228 KB |
Output is correct |
14 |
Correct |
44 ms |
34128 KB |
Output is correct |
15 |
Correct |
27 ms |
33976 KB |
Output is correct |
16 |
Correct |
28 ms |
33872 KB |
Output is correct |
17 |
Correct |
23 ms |
33872 KB |
Output is correct |
18 |
Correct |
29 ms |
33872 KB |
Output is correct |
19 |
Correct |
23 ms |
33884 KB |
Output is correct |
20 |
Correct |
26 ms |
34032 KB |
Output is correct |
21 |
Correct |
27 ms |
33872 KB |
Output is correct |
22 |
Correct |
26 ms |
33872 KB |
Output is correct |
23 |
Correct |
29 ms |
33872 KB |
Output is correct |
24 |
Correct |
25 ms |
33864 KB |
Output is correct |
25 |
Correct |
30 ms |
33872 KB |
Output is correct |
26 |
Correct |
29 ms |
33872 KB |
Output is correct |
27 |
Correct |
28 ms |
33872 KB |
Output is correct |
28 |
Correct |
27 ms |
34040 KB |
Output is correct |
29 |
Correct |
28 ms |
33864 KB |
Output is correct |
30 |
Correct |
46 ms |
33872 KB |
Output is correct |
31 |
Correct |
30 ms |
33872 KB |
Output is correct |
32 |
Correct |
42 ms |
33872 KB |
Output is correct |
33 |
Correct |
31 ms |
33872 KB |
Output is correct |
34 |
Correct |
28 ms |
33872 KB |
Output is correct |
35 |
Correct |
25 ms |
33868 KB |
Output is correct |
36 |
Correct |
26 ms |
33872 KB |
Output is correct |
37 |
Correct |
25 ms |
33872 KB |
Output is correct |
38 |
Correct |
27 ms |
34100 KB |
Output is correct |
39 |
Correct |
26 ms |
34072 KB |
Output is correct |
40 |
Correct |
30 ms |
33872 KB |
Output is correct |
41 |
Correct |
26 ms |
33872 KB |
Output is correct |
42 |
Correct |
30 ms |
33872 KB |
Output is correct |
43 |
Correct |
34 ms |
34100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
33992 KB |
Output is correct |
2 |
Correct |
25 ms |
33872 KB |
Output is correct |
3 |
Correct |
25 ms |
33872 KB |
Output is correct |
4 |
Correct |
23 ms |
33872 KB |
Output is correct |
5 |
Correct |
25 ms |
33872 KB |
Output is correct |
6 |
Correct |
25 ms |
33864 KB |
Output is correct |
7 |
Correct |
25 ms |
34128 KB |
Output is correct |
8 |
Correct |
26 ms |
33872 KB |
Output is correct |
9 |
Correct |
24 ms |
34048 KB |
Output is correct |
10 |
Correct |
25 ms |
33864 KB |
Output is correct |
11 |
Correct |
191 ms |
33872 KB |
Output is correct |
12 |
Correct |
22 ms |
33872 KB |
Output is correct |
13 |
Correct |
196 ms |
33872 KB |
Output is correct |
14 |
Correct |
23 ms |
33864 KB |
Output is correct |
15 |
Correct |
212 ms |
33872 KB |
Output is correct |
16 |
Correct |
196 ms |
33864 KB |
Output is correct |
17 |
Correct |
210 ms |
33872 KB |
Output is correct |
18 |
Correct |
194 ms |
33872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
33864 KB |
Output is correct |
2 |
Correct |
21 ms |
33872 KB |
Output is correct |
3 |
Correct |
25 ms |
34000 KB |
Output is correct |
4 |
Correct |
29 ms |
34140 KB |
Output is correct |
5 |
Correct |
33 ms |
34128 KB |
Output is correct |
6 |
Correct |
27 ms |
33864 KB |
Output is correct |
7 |
Correct |
26 ms |
33888 KB |
Output is correct |
8 |
Correct |
24 ms |
33872 KB |
Output is correct |
9 |
Correct |
31 ms |
33872 KB |
Output is correct |
10 |
Correct |
27 ms |
33872 KB |
Output is correct |
11 |
Correct |
34 ms |
34128 KB |
Output is correct |
12 |
Correct |
31 ms |
34128 KB |
Output is correct |
13 |
Correct |
25 ms |
34228 KB |
Output is correct |
14 |
Correct |
44 ms |
34128 KB |
Output is correct |
15 |
Correct |
27 ms |
33976 KB |
Output is correct |
16 |
Correct |
28 ms |
33872 KB |
Output is correct |
17 |
Correct |
23 ms |
33872 KB |
Output is correct |
18 |
Correct |
29 ms |
33872 KB |
Output is correct |
19 |
Correct |
23 ms |
33884 KB |
Output is correct |
20 |
Correct |
26 ms |
34032 KB |
Output is correct |
21 |
Correct |
27 ms |
33872 KB |
Output is correct |
22 |
Correct |
26 ms |
33872 KB |
Output is correct |
23 |
Correct |
29 ms |
33872 KB |
Output is correct |
24 |
Correct |
25 ms |
33864 KB |
Output is correct |
25 |
Correct |
30 ms |
33872 KB |
Output is correct |
26 |
Correct |
29 ms |
33872 KB |
Output is correct |
27 |
Correct |
28 ms |
33872 KB |
Output is correct |
28 |
Correct |
27 ms |
34040 KB |
Output is correct |
29 |
Correct |
28 ms |
33864 KB |
Output is correct |
30 |
Correct |
46 ms |
33872 KB |
Output is correct |
31 |
Correct |
30 ms |
33872 KB |
Output is correct |
32 |
Correct |
42 ms |
33872 KB |
Output is correct |
33 |
Correct |
31 ms |
33872 KB |
Output is correct |
34 |
Correct |
28 ms |
33872 KB |
Output is correct |
35 |
Correct |
25 ms |
33868 KB |
Output is correct |
36 |
Correct |
26 ms |
33872 KB |
Output is correct |
37 |
Correct |
25 ms |
33872 KB |
Output is correct |
38 |
Correct |
27 ms |
34100 KB |
Output is correct |
39 |
Correct |
26 ms |
34072 KB |
Output is correct |
40 |
Correct |
30 ms |
33872 KB |
Output is correct |
41 |
Correct |
26 ms |
33872 KB |
Output is correct |
42 |
Correct |
30 ms |
33872 KB |
Output is correct |
43 |
Correct |
34 ms |
34100 KB |
Output is correct |
44 |
Correct |
154 ms |
34104 KB |
Output is correct |
45 |
Correct |
24 ms |
34036 KB |
Output is correct |
46 |
Correct |
35 ms |
34096 KB |
Output is correct |
47 |
Correct |
37 ms |
33872 KB |
Output is correct |
48 |
Correct |
31 ms |
33872 KB |
Output is correct |
49 |
Correct |
34 ms |
34040 KB |
Output is correct |
50 |
Correct |
35 ms |
33924 KB |
Output is correct |
51 |
Correct |
55 ms |
33872 KB |
Output is correct |
52 |
Correct |
25 ms |
34300 KB |
Output is correct |
53 |
Correct |
1274 ms |
34128 KB |
Output is correct |
54 |
Correct |
64 ms |
33872 KB |
Output is correct |
55 |
Correct |
25 ms |
33884 KB |
Output is correct |
56 |
Correct |
26 ms |
34128 KB |
Output is correct |
57 |
Correct |
22 ms |
33872 KB |
Output is correct |
58 |
Correct |
1070 ms |
34296 KB |
Output is correct |
59 |
Correct |
38 ms |
34104 KB |
Output is correct |
60 |
Correct |
28 ms |
33900 KB |
Output is correct |
61 |
Correct |
35 ms |
33872 KB |
Output is correct |
62 |
Correct |
35 ms |
33872 KB |
Output is correct |
63 |
Correct |
149 ms |
33884 KB |
Output is correct |
64 |
Correct |
95 ms |
33872 KB |
Output is correct |
65 |
Correct |
32 ms |
34100 KB |
Output is correct |
66 |
Correct |
36 ms |
33884 KB |
Output is correct |
67 |
Correct |
75 ms |
33872 KB |
Output is correct |
68 |
Correct |
88 ms |
33872 KB |
Output is correct |
69 |
Correct |
30 ms |
33872 KB |
Output is correct |
70 |
Correct |
39 ms |
33888 KB |
Output is correct |
71 |
Correct |
74 ms |
33872 KB |
Output is correct |
72 |
Correct |
67 ms |
34100 KB |
Output is correct |
73 |
Correct |
28 ms |
33872 KB |
Output is correct |
74 |
Correct |
42 ms |
33872 KB |
Output is correct |
75 |
Correct |
55 ms |
33872 KB |
Output is correct |
76 |
Correct |
45 ms |
34132 KB |
Output is correct |
77 |
Correct |
47 ms |
33864 KB |
Output is correct |
78 |
Correct |
26 ms |
33872 KB |
Output is correct |
79 |
Correct |
33 ms |
33864 KB |
Output is correct |
80 |
Correct |
60 ms |
34120 KB |
Output is correct |
81 |
Correct |
41 ms |
34096 KB |
Output is correct |
82 |
Correct |
26 ms |
33864 KB |
Output is correct |
83 |
Correct |
34 ms |
34040 KB |
Output is correct |
84 |
Correct |
40 ms |
34108 KB |
Output is correct |
85 |
Correct |
27 ms |
33912 KB |
Output is correct |
86 |
Correct |
40 ms |
33872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
33864 KB |
Output is correct |
2 |
Correct |
21 ms |
33872 KB |
Output is correct |
3 |
Correct |
25 ms |
34000 KB |
Output is correct |
4 |
Correct |
29 ms |
34140 KB |
Output is correct |
5 |
Correct |
33 ms |
34128 KB |
Output is correct |
6 |
Correct |
27 ms |
33864 KB |
Output is correct |
7 |
Correct |
26 ms |
33888 KB |
Output is correct |
8 |
Correct |
24 ms |
33872 KB |
Output is correct |
9 |
Correct |
31 ms |
33872 KB |
Output is correct |
10 |
Correct |
27 ms |
33872 KB |
Output is correct |
11 |
Correct |
34 ms |
34128 KB |
Output is correct |
12 |
Correct |
31 ms |
34128 KB |
Output is correct |
13 |
Correct |
25 ms |
34228 KB |
Output is correct |
14 |
Correct |
44 ms |
34128 KB |
Output is correct |
15 |
Correct |
27 ms |
33976 KB |
Output is correct |
16 |
Correct |
28 ms |
33872 KB |
Output is correct |
17 |
Correct |
23 ms |
33872 KB |
Output is correct |
18 |
Correct |
29 ms |
33872 KB |
Output is correct |
19 |
Correct |
23 ms |
33884 KB |
Output is correct |
20 |
Correct |
26 ms |
34032 KB |
Output is correct |
21 |
Correct |
27 ms |
33872 KB |
Output is correct |
22 |
Correct |
26 ms |
33872 KB |
Output is correct |
23 |
Correct |
29 ms |
33872 KB |
Output is correct |
24 |
Correct |
25 ms |
33864 KB |
Output is correct |
25 |
Correct |
30 ms |
33872 KB |
Output is correct |
26 |
Correct |
29 ms |
33872 KB |
Output is correct |
27 |
Correct |
28 ms |
33872 KB |
Output is correct |
28 |
Correct |
27 ms |
34040 KB |
Output is correct |
29 |
Correct |
28 ms |
33864 KB |
Output is correct |
30 |
Correct |
46 ms |
33872 KB |
Output is correct |
31 |
Correct |
30 ms |
33872 KB |
Output is correct |
32 |
Correct |
42 ms |
33872 KB |
Output is correct |
33 |
Correct |
31 ms |
33872 KB |
Output is correct |
34 |
Correct |
28 ms |
33872 KB |
Output is correct |
35 |
Correct |
25 ms |
33868 KB |
Output is correct |
36 |
Correct |
26 ms |
33872 KB |
Output is correct |
37 |
Correct |
25 ms |
33872 KB |
Output is correct |
38 |
Correct |
27 ms |
34100 KB |
Output is correct |
39 |
Correct |
26 ms |
34072 KB |
Output is correct |
40 |
Correct |
30 ms |
33872 KB |
Output is correct |
41 |
Correct |
26 ms |
33872 KB |
Output is correct |
42 |
Correct |
30 ms |
33872 KB |
Output is correct |
43 |
Correct |
34 ms |
34100 KB |
Output is correct |
44 |
Correct |
24 ms |
33872 KB |
Output is correct |
45 |
Correct |
150 ms |
33872 KB |
Output is correct |
46 |
Correct |
1843 ms |
34296 KB |
Output is correct |
47 |
Correct |
143 ms |
33884 KB |
Output is correct |
48 |
Correct |
137 ms |
33872 KB |
Output is correct |
49 |
Correct |
1865 ms |
34376 KB |
Output is correct |
50 |
Execution timed out |
3054 ms |
34888 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |