Submission #1103710

# Submission time Handle Problem Language Result Execution time Memory
1103710 2024-10-21T14:48:48 Z ortsac Political Development (BOI17_politicaldevelopment) C++17
77 / 100
3000 ms 34888 KB
#pragma GCC optimize ("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";
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 33992 KB Output is correct
2 Correct 20 ms 33872 KB Output is correct
3 Correct 24 ms 33872 KB Output is correct
4 Correct 29 ms 34128 KB Output is correct
5 Correct 31 ms 33932 KB Output is correct
6 Correct 23 ms 33872 KB Output is correct
7 Correct 35 ms 33872 KB Output is correct
8 Correct 24 ms 33872 KB Output is correct
9 Correct 26 ms 33884 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 33992 KB Output is correct
2 Correct 20 ms 33872 KB Output is correct
3 Correct 24 ms 33872 KB Output is correct
4 Correct 29 ms 34128 KB Output is correct
5 Correct 31 ms 33932 KB Output is correct
6 Correct 23 ms 33872 KB Output is correct
7 Correct 35 ms 33872 KB Output is correct
8 Correct 24 ms 33872 KB Output is correct
9 Correct 26 ms 33884 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 30 ms 34120 KB Output is correct
12 Correct 31 ms 34128 KB Output is correct
13 Correct 24 ms 33984 KB Output is correct
14 Correct 42 ms 34128 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 28 ms 33980 KB Output is correct
17 Correct 24 ms 33872 KB Output is correct
18 Correct 26 ms 33872 KB Output is correct
19 Correct 25 ms 33864 KB Output is correct
20 Correct 25 ms 34076 KB Output is correct
21 Correct 27 ms 33872 KB Output is correct
22 Correct 25 ms 33872 KB Output is correct
23 Correct 26 ms 33872 KB Output is correct
24 Correct 25 ms 34128 KB Output is correct
25 Correct 27 ms 33872 KB Output is correct
26 Correct 27 ms 33872 KB Output is correct
27 Correct 27 ms 33864 KB Output is correct
28 Correct 26 ms 33872 KB Output is correct
29 Correct 26 ms 33872 KB Output is correct
30 Correct 41 ms 33864 KB Output is correct
31 Correct 29 ms 33872 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 29 ms 34092 KB Output is correct
34 Correct 30 ms 33872 KB Output is correct
35 Correct 35 ms 33872 KB Output is correct
36 Correct 26 ms 34040 KB Output is correct
37 Correct 27 ms 33872 KB Output is correct
38 Correct 23 ms 33872 KB Output is correct
39 Correct 24 ms 33872 KB Output is correct
40 Correct 30 ms 33888 KB Output is correct
41 Correct 25 ms 33872 KB Output is correct
42 Correct 31 ms 33872 KB Output is correct
43 Correct 31 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 33872 KB Output is correct
2 Correct 23 ms 33872 KB Output is correct
3 Correct 24 ms 34112 KB Output is correct
4 Correct 25 ms 33872 KB Output is correct
5 Correct 26 ms 33872 KB Output is correct
6 Correct 26 ms 33872 KB Output is correct
7 Correct 24 ms 33872 KB Output is correct
8 Correct 23 ms 33872 KB Output is correct
9 Correct 23 ms 33872 KB Output is correct
10 Correct 25 ms 33872 KB Output is correct
11 Correct 185 ms 33864 KB Output is correct
12 Correct 22 ms 33872 KB Output is correct
13 Correct 190 ms 33872 KB Output is correct
14 Correct 23 ms 33872 KB Output is correct
15 Correct 187 ms 34092 KB Output is correct
16 Correct 185 ms 34096 KB Output is correct
17 Correct 192 ms 33864 KB Output is correct
18 Correct 187 ms 34096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 33992 KB Output is correct
2 Correct 20 ms 33872 KB Output is correct
3 Correct 24 ms 33872 KB Output is correct
4 Correct 29 ms 34128 KB Output is correct
5 Correct 31 ms 33932 KB Output is correct
6 Correct 23 ms 33872 KB Output is correct
7 Correct 35 ms 33872 KB Output is correct
8 Correct 24 ms 33872 KB Output is correct
9 Correct 26 ms 33884 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 30 ms 34120 KB Output is correct
12 Correct 31 ms 34128 KB Output is correct
13 Correct 24 ms 33984 KB Output is correct
14 Correct 42 ms 34128 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 28 ms 33980 KB Output is correct
17 Correct 24 ms 33872 KB Output is correct
18 Correct 26 ms 33872 KB Output is correct
19 Correct 25 ms 33864 KB Output is correct
20 Correct 25 ms 34076 KB Output is correct
21 Correct 27 ms 33872 KB Output is correct
22 Correct 25 ms 33872 KB Output is correct
23 Correct 26 ms 33872 KB Output is correct
24 Correct 25 ms 34128 KB Output is correct
25 Correct 27 ms 33872 KB Output is correct
26 Correct 27 ms 33872 KB Output is correct
27 Correct 27 ms 33864 KB Output is correct
28 Correct 26 ms 33872 KB Output is correct
29 Correct 26 ms 33872 KB Output is correct
30 Correct 41 ms 33864 KB Output is correct
31 Correct 29 ms 33872 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 29 ms 34092 KB Output is correct
34 Correct 30 ms 33872 KB Output is correct
35 Correct 35 ms 33872 KB Output is correct
36 Correct 26 ms 34040 KB Output is correct
37 Correct 27 ms 33872 KB Output is correct
38 Correct 23 ms 33872 KB Output is correct
39 Correct 24 ms 33872 KB Output is correct
40 Correct 30 ms 33888 KB Output is correct
41 Correct 25 ms 33872 KB Output is correct
42 Correct 31 ms 33872 KB Output is correct
43 Correct 31 ms 33872 KB Output is correct
44 Correct 159 ms 34100 KB Output is correct
45 Correct 25 ms 33864 KB Output is correct
46 Correct 30 ms 33864 KB Output is correct
47 Correct 38 ms 33872 KB Output is correct
48 Correct 31 ms 33872 KB Output is correct
49 Correct 39 ms 33876 KB Output is correct
50 Correct 39 ms 33872 KB Output is correct
51 Correct 60 ms 33884 KB Output is correct
52 Correct 35 ms 34128 KB Output is correct
53 Correct 1198 ms 34292 KB Output is correct
54 Correct 64 ms 33872 KB Output is correct
55 Correct 26 ms 33872 KB Output is correct
56 Correct 25 ms 33980 KB Output is correct
57 Correct 23 ms 34044 KB Output is correct
58 Correct 1008 ms 34128 KB Output is correct
59 Correct 46 ms 33872 KB Output is correct
60 Correct 27 ms 33872 KB Output is correct
61 Correct 34 ms 33940 KB Output is correct
62 Correct 34 ms 33864 KB Output is correct
63 Correct 140 ms 34096 KB Output is correct
64 Correct 86 ms 33872 KB Output is correct
65 Correct 29 ms 33888 KB Output is correct
66 Correct 35 ms 33872 KB Output is correct
67 Correct 74 ms 33872 KB Output is correct
68 Correct 85 ms 33864 KB Output is correct
69 Correct 30 ms 34040 KB Output is correct
70 Correct 40 ms 33872 KB Output is correct
71 Correct 73 ms 33872 KB Output is correct
72 Correct 61 ms 34092 KB Output is correct
73 Correct 34 ms 34140 KB Output is correct
74 Correct 43 ms 33872 KB Output is correct
75 Correct 58 ms 33864 KB Output is correct
76 Correct 53 ms 33872 KB Output is correct
77 Correct 47 ms 33884 KB Output is correct
78 Correct 27 ms 33872 KB Output is correct
79 Correct 37 ms 33864 KB Output is correct
80 Correct 55 ms 33940 KB Output is correct
81 Correct 57 ms 33864 KB Output is correct
82 Correct 26 ms 33872 KB Output is correct
83 Correct 36 ms 33872 KB Output is correct
84 Correct 43 ms 34044 KB Output is correct
85 Correct 28 ms 33872 KB Output is correct
86 Correct 41 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 33992 KB Output is correct
2 Correct 20 ms 33872 KB Output is correct
3 Correct 24 ms 33872 KB Output is correct
4 Correct 29 ms 34128 KB Output is correct
5 Correct 31 ms 33932 KB Output is correct
6 Correct 23 ms 33872 KB Output is correct
7 Correct 35 ms 33872 KB Output is correct
8 Correct 24 ms 33872 KB Output is correct
9 Correct 26 ms 33884 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 30 ms 34120 KB Output is correct
12 Correct 31 ms 34128 KB Output is correct
13 Correct 24 ms 33984 KB Output is correct
14 Correct 42 ms 34128 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 28 ms 33980 KB Output is correct
17 Correct 24 ms 33872 KB Output is correct
18 Correct 26 ms 33872 KB Output is correct
19 Correct 25 ms 33864 KB Output is correct
20 Correct 25 ms 34076 KB Output is correct
21 Correct 27 ms 33872 KB Output is correct
22 Correct 25 ms 33872 KB Output is correct
23 Correct 26 ms 33872 KB Output is correct
24 Correct 25 ms 34128 KB Output is correct
25 Correct 27 ms 33872 KB Output is correct
26 Correct 27 ms 33872 KB Output is correct
27 Correct 27 ms 33864 KB Output is correct
28 Correct 26 ms 33872 KB Output is correct
29 Correct 26 ms 33872 KB Output is correct
30 Correct 41 ms 33864 KB Output is correct
31 Correct 29 ms 33872 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 29 ms 34092 KB Output is correct
34 Correct 30 ms 33872 KB Output is correct
35 Correct 35 ms 33872 KB Output is correct
36 Correct 26 ms 34040 KB Output is correct
37 Correct 27 ms 33872 KB Output is correct
38 Correct 23 ms 33872 KB Output is correct
39 Correct 24 ms 33872 KB Output is correct
40 Correct 30 ms 33888 KB Output is correct
41 Correct 25 ms 33872 KB Output is correct
42 Correct 31 ms 33872 KB Output is correct
43 Correct 31 ms 33872 KB Output is correct
44 Correct 26 ms 33872 KB Output is correct
45 Correct 147 ms 34096 KB Output is correct
46 Correct 1883 ms 34128 KB Output is correct
47 Correct 150 ms 33872 KB Output is correct
48 Correct 138 ms 34100 KB Output is correct
49 Correct 1688 ms 34524 KB Output is correct
50 Execution timed out 3075 ms 34888 KB Time limit exceeded
51 Halted 0 ms 0 KB -