Submission #1103711

# Submission time Handle Problem Language Result Execution time Memory
1103711 2024-10-21T14:49:43 Z ortsac Political Development (BOI17_politicaldevelopment) C++17
77 / 100
3000 ms 34888 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#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 26 ms 33872 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 27 ms 33872 KB Output is correct
4 Correct 30 ms 34128 KB Output is correct
5 Correct 30 ms 34120 KB Output is correct
6 Correct 27 ms 33872 KB Output is correct
7 Correct 27 ms 33872 KB Output is correct
8 Correct 27 ms 33884 KB Output is correct
9 Correct 22 ms 33872 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 33872 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 27 ms 33872 KB Output is correct
4 Correct 30 ms 34128 KB Output is correct
5 Correct 30 ms 34120 KB Output is correct
6 Correct 27 ms 33872 KB Output is correct
7 Correct 27 ms 33872 KB Output is correct
8 Correct 27 ms 33884 KB Output is correct
9 Correct 22 ms 33872 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 29 ms 34128 KB Output is correct
12 Correct 34 ms 34120 KB Output is correct
13 Correct 24 ms 34080 KB Output is correct
14 Correct 41 ms 34120 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 26 ms 33872 KB Output is correct
17 Correct 24 ms 33864 KB Output is correct
18 Correct 27 ms 33872 KB Output is correct
19 Correct 27 ms 33872 KB Output is correct
20 Correct 26 ms 33988 KB Output is correct
21 Correct 26 ms 33864 KB Output is correct
22 Correct 27 ms 33872 KB Output is correct
23 Correct 27 ms 33872 KB Output is correct
24 Correct 23 ms 34040 KB Output is correct
25 Correct 27 ms 34100 KB Output is correct
26 Correct 25 ms 33872 KB Output is correct
27 Correct 28 ms 33872 KB Output is correct
28 Correct 28 ms 33872 KB Output is correct
29 Correct 25 ms 34084 KB Output is correct
30 Correct 46 ms 34132 KB Output is correct
31 Correct 28 ms 33864 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 27 ms 34092 KB Output is correct
34 Correct 26 ms 33864 KB Output is correct
35 Correct 23 ms 33872 KB Output is correct
36 Correct 24 ms 33872 KB Output is correct
37 Correct 23 ms 33872 KB Output is correct
38 Correct 23 ms 34052 KB Output is correct
39 Correct 23 ms 33872 KB Output is correct
40 Correct 35 ms 33872 KB Output is correct
41 Correct 24 ms 34040 KB Output is correct
42 Correct 28 ms 33872 KB Output is correct
43 Correct 28 ms 34104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 33992 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 24 ms 33872 KB Output is correct
4 Correct 23 ms 33872 KB Output is correct
5 Correct 23 ms 34088 KB Output is correct
6 Correct 23 ms 34036 KB Output is correct
7 Correct 21 ms 33872 KB Output is correct
8 Correct 22 ms 33872 KB Output is correct
9 Correct 21 ms 33908 KB Output is correct
10 Correct 22 ms 33872 KB Output is correct
11 Correct 179 ms 34092 KB Output is correct
12 Correct 22 ms 33872 KB Output is correct
13 Correct 179 ms 34092 KB Output is correct
14 Correct 21 ms 34036 KB Output is correct
15 Correct 193 ms 34096 KB Output is correct
16 Correct 185 ms 33872 KB Output is correct
17 Correct 237 ms 33872 KB Output is correct
18 Correct 202 ms 34096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 33872 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 27 ms 33872 KB Output is correct
4 Correct 30 ms 34128 KB Output is correct
5 Correct 30 ms 34120 KB Output is correct
6 Correct 27 ms 33872 KB Output is correct
7 Correct 27 ms 33872 KB Output is correct
8 Correct 27 ms 33884 KB Output is correct
9 Correct 22 ms 33872 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 29 ms 34128 KB Output is correct
12 Correct 34 ms 34120 KB Output is correct
13 Correct 24 ms 34080 KB Output is correct
14 Correct 41 ms 34120 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 26 ms 33872 KB Output is correct
17 Correct 24 ms 33864 KB Output is correct
18 Correct 27 ms 33872 KB Output is correct
19 Correct 27 ms 33872 KB Output is correct
20 Correct 26 ms 33988 KB Output is correct
21 Correct 26 ms 33864 KB Output is correct
22 Correct 27 ms 33872 KB Output is correct
23 Correct 27 ms 33872 KB Output is correct
24 Correct 23 ms 34040 KB Output is correct
25 Correct 27 ms 34100 KB Output is correct
26 Correct 25 ms 33872 KB Output is correct
27 Correct 28 ms 33872 KB Output is correct
28 Correct 28 ms 33872 KB Output is correct
29 Correct 25 ms 34084 KB Output is correct
30 Correct 46 ms 34132 KB Output is correct
31 Correct 28 ms 33864 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 27 ms 34092 KB Output is correct
34 Correct 26 ms 33864 KB Output is correct
35 Correct 23 ms 33872 KB Output is correct
36 Correct 24 ms 33872 KB Output is correct
37 Correct 23 ms 33872 KB Output is correct
38 Correct 23 ms 34052 KB Output is correct
39 Correct 23 ms 33872 KB Output is correct
40 Correct 35 ms 33872 KB Output is correct
41 Correct 24 ms 34040 KB Output is correct
42 Correct 28 ms 33872 KB Output is correct
43 Correct 28 ms 34104 KB Output is correct
44 Correct 152 ms 33872 KB Output is correct
45 Correct 24 ms 33872 KB Output is correct
46 Correct 33 ms 33864 KB Output is correct
47 Correct 38 ms 33872 KB Output is correct
48 Correct 45 ms 33888 KB Output is correct
49 Correct 38 ms 33872 KB Output is correct
50 Correct 37 ms 33940 KB Output is correct
51 Correct 66 ms 34108 KB Output is correct
52 Correct 30 ms 34124 KB Output is correct
53 Correct 1419 ms 34296 KB Output is correct
54 Correct 91 ms 34096 KB Output is correct
55 Correct 30 ms 34072 KB Output is correct
56 Correct 26 ms 34152 KB Output is correct
57 Correct 24 ms 33872 KB Output is correct
58 Correct 1046 ms 34128 KB Output is correct
59 Correct 35 ms 33864 KB Output is correct
60 Correct 28 ms 33864 KB Output is correct
61 Correct 34 ms 33900 KB Output is correct
62 Correct 35 ms 33864 KB Output is correct
63 Correct 140 ms 33856 KB Output is correct
64 Correct 87 ms 33872 KB Output is correct
65 Correct 31 ms 33872 KB Output is correct
66 Correct 32 ms 33872 KB Output is correct
67 Correct 73 ms 34044 KB Output is correct
68 Correct 88 ms 33872 KB Output is correct
69 Correct 31 ms 33872 KB Output is correct
70 Correct 40 ms 34088 KB Output is correct
71 Correct 69 ms 33872 KB Output is correct
72 Correct 57 ms 33864 KB Output is correct
73 Correct 27 ms 33872 KB Output is correct
74 Correct 40 ms 33872 KB Output is correct
75 Correct 56 ms 34104 KB Output is correct
76 Correct 46 ms 33864 KB Output is correct
77 Correct 47 ms 33864 KB Output is correct
78 Correct 26 ms 33872 KB Output is correct
79 Correct 34 ms 33872 KB Output is correct
80 Correct 54 ms 34128 KB Output is correct
81 Correct 47 ms 33872 KB Output is correct
82 Correct 25 ms 33872 KB Output is correct
83 Correct 33 ms 33964 KB Output is correct
84 Correct 36 ms 33872 KB Output is correct
85 Correct 23 ms 33864 KB Output is correct
86 Correct 34 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 33872 KB Output is correct
2 Correct 24 ms 33872 KB Output is correct
3 Correct 27 ms 33872 KB Output is correct
4 Correct 30 ms 34128 KB Output is correct
5 Correct 30 ms 34120 KB Output is correct
6 Correct 27 ms 33872 KB Output is correct
7 Correct 27 ms 33872 KB Output is correct
8 Correct 27 ms 33884 KB Output is correct
9 Correct 22 ms 33872 KB Output is correct
10 Correct 26 ms 33872 KB Output is correct
11 Correct 29 ms 34128 KB Output is correct
12 Correct 34 ms 34120 KB Output is correct
13 Correct 24 ms 34080 KB Output is correct
14 Correct 41 ms 34120 KB Output is correct
15 Correct 23 ms 33872 KB Output is correct
16 Correct 26 ms 33872 KB Output is correct
17 Correct 24 ms 33864 KB Output is correct
18 Correct 27 ms 33872 KB Output is correct
19 Correct 27 ms 33872 KB Output is correct
20 Correct 26 ms 33988 KB Output is correct
21 Correct 26 ms 33864 KB Output is correct
22 Correct 27 ms 33872 KB Output is correct
23 Correct 27 ms 33872 KB Output is correct
24 Correct 23 ms 34040 KB Output is correct
25 Correct 27 ms 34100 KB Output is correct
26 Correct 25 ms 33872 KB Output is correct
27 Correct 28 ms 33872 KB Output is correct
28 Correct 28 ms 33872 KB Output is correct
29 Correct 25 ms 34084 KB Output is correct
30 Correct 46 ms 34132 KB Output is correct
31 Correct 28 ms 33864 KB Output is correct
32 Correct 41 ms 33872 KB Output is correct
33 Correct 27 ms 34092 KB Output is correct
34 Correct 26 ms 33864 KB Output is correct
35 Correct 23 ms 33872 KB Output is correct
36 Correct 24 ms 33872 KB Output is correct
37 Correct 23 ms 33872 KB Output is correct
38 Correct 23 ms 34052 KB Output is correct
39 Correct 23 ms 33872 KB Output is correct
40 Correct 35 ms 33872 KB Output is correct
41 Correct 24 ms 34040 KB Output is correct
42 Correct 28 ms 33872 KB Output is correct
43 Correct 28 ms 34104 KB Output is correct
44 Correct 22 ms 33872 KB Output is correct
45 Correct 141 ms 33872 KB Output is correct
46 Correct 1834 ms 34216 KB Output is correct
47 Correct 127 ms 33872 KB Output is correct
48 Correct 129 ms 33872 KB Output is correct
49 Correct 1776 ms 34508 KB Output is correct
50 Execution timed out 3069 ms 34888 KB Time limit exceeded
51 Halted 0 ms 0 KB -