답안 #1103685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103685 2024-10-21T14:24:35 Z ortsac Political Development (BOI17_politicaldevelopment) C++17
77 / 100
3000 ms 37196 KB
#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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33872 KB Output is correct
2 Correct 25 ms 33864 KB Output is correct
3 Correct 29 ms 34320 KB Output is correct
4 Correct 34 ms 34116 KB Output is correct
5 Correct 33 ms 34120 KB Output is correct
6 Correct 28 ms 34128 KB Output is correct
7 Correct 30 ms 34128 KB Output is correct
8 Correct 28 ms 34044 KB Output is correct
9 Correct 26 ms 33872 KB Output is correct
10 Correct 25 ms 34060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33872 KB Output is correct
2 Correct 25 ms 33864 KB Output is correct
3 Correct 29 ms 34320 KB Output is correct
4 Correct 34 ms 34116 KB Output is correct
5 Correct 33 ms 34120 KB Output is correct
6 Correct 28 ms 34128 KB Output is correct
7 Correct 30 ms 34128 KB Output is correct
8 Correct 28 ms 34044 KB Output is correct
9 Correct 26 ms 33872 KB Output is correct
10 Correct 25 ms 34060 KB Output is correct
11 Correct 32 ms 34184 KB Output is correct
12 Correct 32 ms 34120 KB Output is correct
13 Correct 26 ms 33872 KB Output is correct
14 Correct 45 ms 34128 KB Output is correct
15 Correct 25 ms 33872 KB Output is correct
16 Correct 30 ms 34104 KB Output is correct
17 Correct 26 ms 33872 KB Output is correct
18 Correct 32 ms 34120 KB Output is correct
19 Correct 26 ms 33888 KB Output is correct
20 Correct 25 ms 34128 KB Output is correct
21 Correct 28 ms 34120 KB Output is correct
22 Correct 25 ms 34128 KB Output is correct
23 Correct 29 ms 34168 KB Output is correct
24 Correct 24 ms 34124 KB Output is correct
25 Correct 29 ms 34128 KB Output is correct
26 Correct 31 ms 34092 KB Output is correct
27 Correct 30 ms 34384 KB Output is correct
28 Correct 29 ms 34140 KB Output is correct
29 Correct 29 ms 34140 KB Output is correct
30 Correct 40 ms 34120 KB Output is correct
31 Correct 31 ms 34120 KB Output is correct
32 Correct 43 ms 34120 KB Output is correct
33 Correct 32 ms 34140 KB Output is correct
34 Correct 29 ms 34132 KB Output is correct
35 Correct 25 ms 34128 KB Output is correct
36 Correct 33 ms 34128 KB Output is correct
37 Correct 25 ms 34128 KB Output is correct
38 Correct 26 ms 34128 KB Output is correct
39 Correct 24 ms 34296 KB Output is correct
40 Correct 31 ms 34296 KB Output is correct
41 Correct 26 ms 34120 KB Output is correct
42 Correct 29 ms 34128 KB Output is correct
43 Correct 31 ms 34128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 34124 KB Output is correct
2 Correct 25 ms 33872 KB Output is correct
3 Correct 26 ms 34120 KB Output is correct
4 Correct 24 ms 34104 KB Output is correct
5 Correct 25 ms 33864 KB Output is correct
6 Correct 30 ms 34108 KB Output is correct
7 Correct 27 ms 33868 KB Output is correct
8 Correct 25 ms 34092 KB Output is correct
9 Correct 24 ms 33872 KB Output is correct
10 Correct 22 ms 33864 KB Output is correct
11 Correct 206 ms 36684 KB Output is correct
12 Correct 23 ms 34104 KB Output is correct
13 Correct 212 ms 36680 KB Output is correct
14 Correct 22 ms 33900 KB Output is correct
15 Correct 205 ms 36680 KB Output is correct
16 Correct 195 ms 36584 KB Output is correct
17 Correct 191 ms 36680 KB Output is correct
18 Correct 210 ms 36512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33872 KB Output is correct
2 Correct 25 ms 33864 KB Output is correct
3 Correct 29 ms 34320 KB Output is correct
4 Correct 34 ms 34116 KB Output is correct
5 Correct 33 ms 34120 KB Output is correct
6 Correct 28 ms 34128 KB Output is correct
7 Correct 30 ms 34128 KB Output is correct
8 Correct 28 ms 34044 KB Output is correct
9 Correct 26 ms 33872 KB Output is correct
10 Correct 25 ms 34060 KB Output is correct
11 Correct 32 ms 34184 KB Output is correct
12 Correct 32 ms 34120 KB Output is correct
13 Correct 26 ms 33872 KB Output is correct
14 Correct 45 ms 34128 KB Output is correct
15 Correct 25 ms 33872 KB Output is correct
16 Correct 30 ms 34104 KB Output is correct
17 Correct 26 ms 33872 KB Output is correct
18 Correct 32 ms 34120 KB Output is correct
19 Correct 26 ms 33888 KB Output is correct
20 Correct 25 ms 34128 KB Output is correct
21 Correct 28 ms 34120 KB Output is correct
22 Correct 25 ms 34128 KB Output is correct
23 Correct 29 ms 34168 KB Output is correct
24 Correct 24 ms 34124 KB Output is correct
25 Correct 29 ms 34128 KB Output is correct
26 Correct 31 ms 34092 KB Output is correct
27 Correct 30 ms 34384 KB Output is correct
28 Correct 29 ms 34140 KB Output is correct
29 Correct 29 ms 34140 KB Output is correct
30 Correct 40 ms 34120 KB Output is correct
31 Correct 31 ms 34120 KB Output is correct
32 Correct 43 ms 34120 KB Output is correct
33 Correct 32 ms 34140 KB Output is correct
34 Correct 29 ms 34132 KB Output is correct
35 Correct 25 ms 34128 KB Output is correct
36 Correct 33 ms 34128 KB Output is correct
37 Correct 25 ms 34128 KB Output is correct
38 Correct 26 ms 34128 KB Output is correct
39 Correct 24 ms 34296 KB Output is correct
40 Correct 31 ms 34296 KB Output is correct
41 Correct 26 ms 34120 KB Output is correct
42 Correct 29 ms 34128 KB Output is correct
43 Correct 31 ms 34128 KB Output is correct
44 Correct 149 ms 34128 KB Output is correct
45 Correct 23 ms 34112 KB Output is correct
46 Correct 29 ms 34140 KB Output is correct
47 Correct 37 ms 34128 KB Output is correct
48 Correct 33 ms 34128 KB Output is correct
49 Correct 41 ms 34128 KB Output is correct
50 Correct 43 ms 34120 KB Output is correct
51 Correct 63 ms 34420 KB Output is correct
52 Correct 26 ms 34060 KB Output is correct
53 Correct 1248 ms 34664 KB Output is correct
54 Correct 71 ms 34384 KB Output is correct
55 Correct 27 ms 34120 KB Output is correct
56 Correct 33 ms 34084 KB Output is correct
57 Correct 24 ms 34040 KB Output is correct
58 Correct 1099 ms 34728 KB Output is correct
59 Correct 54 ms 34128 KB Output is correct
60 Correct 28 ms 34128 KB Output is correct
61 Correct 37 ms 34120 KB Output is correct
62 Correct 39 ms 34128 KB Output is correct
63 Correct 161 ms 34120 KB Output is correct
64 Correct 95 ms 34128 KB Output is correct
65 Correct 31 ms 33996 KB Output is correct
66 Correct 36 ms 34204 KB Output is correct
67 Correct 90 ms 34212 KB Output is correct
68 Correct 99 ms 34128 KB Output is correct
69 Correct 33 ms 34128 KB Output is correct
70 Correct 46 ms 34228 KB Output is correct
71 Correct 81 ms 34336 KB Output is correct
72 Correct 58 ms 34328 KB Output is correct
73 Correct 29 ms 34104 KB Output is correct
74 Correct 54 ms 34284 KB Output is correct
75 Correct 98 ms 34124 KB Output is correct
76 Correct 49 ms 34120 KB Output is correct
77 Correct 46 ms 34380 KB Output is correct
78 Correct 39 ms 34148 KB Output is correct
79 Correct 35 ms 34128 KB Output is correct
80 Correct 57 ms 34020 KB Output is correct
81 Correct 47 ms 34376 KB Output is correct
82 Correct 26 ms 34128 KB Output is correct
83 Correct 32 ms 34128 KB Output is correct
84 Correct 39 ms 34128 KB Output is correct
85 Correct 26 ms 33892 KB Output is correct
86 Correct 39 ms 34128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33872 KB Output is correct
2 Correct 25 ms 33864 KB Output is correct
3 Correct 29 ms 34320 KB Output is correct
4 Correct 34 ms 34116 KB Output is correct
5 Correct 33 ms 34120 KB Output is correct
6 Correct 28 ms 34128 KB Output is correct
7 Correct 30 ms 34128 KB Output is correct
8 Correct 28 ms 34044 KB Output is correct
9 Correct 26 ms 33872 KB Output is correct
10 Correct 25 ms 34060 KB Output is correct
11 Correct 32 ms 34184 KB Output is correct
12 Correct 32 ms 34120 KB Output is correct
13 Correct 26 ms 33872 KB Output is correct
14 Correct 45 ms 34128 KB Output is correct
15 Correct 25 ms 33872 KB Output is correct
16 Correct 30 ms 34104 KB Output is correct
17 Correct 26 ms 33872 KB Output is correct
18 Correct 32 ms 34120 KB Output is correct
19 Correct 26 ms 33888 KB Output is correct
20 Correct 25 ms 34128 KB Output is correct
21 Correct 28 ms 34120 KB Output is correct
22 Correct 25 ms 34128 KB Output is correct
23 Correct 29 ms 34168 KB Output is correct
24 Correct 24 ms 34124 KB Output is correct
25 Correct 29 ms 34128 KB Output is correct
26 Correct 31 ms 34092 KB Output is correct
27 Correct 30 ms 34384 KB Output is correct
28 Correct 29 ms 34140 KB Output is correct
29 Correct 29 ms 34140 KB Output is correct
30 Correct 40 ms 34120 KB Output is correct
31 Correct 31 ms 34120 KB Output is correct
32 Correct 43 ms 34120 KB Output is correct
33 Correct 32 ms 34140 KB Output is correct
34 Correct 29 ms 34132 KB Output is correct
35 Correct 25 ms 34128 KB Output is correct
36 Correct 33 ms 34128 KB Output is correct
37 Correct 25 ms 34128 KB Output is correct
38 Correct 26 ms 34128 KB Output is correct
39 Correct 24 ms 34296 KB Output is correct
40 Correct 31 ms 34296 KB Output is correct
41 Correct 26 ms 34120 KB Output is correct
42 Correct 29 ms 34128 KB Output is correct
43 Correct 31 ms 34128 KB Output is correct
44 Correct 25 ms 33872 KB Output is correct
45 Correct 140 ms 35744 KB Output is correct
46 Correct 1806 ms 35228 KB Output is correct
47 Correct 139 ms 35912 KB Output is correct
48 Correct 133 ms 35656 KB Output is correct
49 Correct 1937 ms 35200 KB Output is correct
50 Execution timed out 3069 ms 37196 KB Time limit exceeded
51 Halted 0 ms 0 KB -