Submission #1075414

# Submission time Handle Problem Language Result Execution time Memory
1075414 2024-08-26T05:44:40 Z juicy Race (IOI11_race) C++17
21 / 100
320 ms 262144 KB
#include "race.h"

#include <bits/stdc++.h>

using namespace std;

int best_path(int n, int k, int H[][2], int L[]) {
    vector<vector<array<int, 2>>> g(n);
    for (int i = 0; i < n; ++i) {
        for (auto it : {0, 1}) {
            g[H[i][it]].push_back({H[i][it ^ 1], i});
        }
    }
    vector<map<long long, int>> mp(n);
    function<int(int, int, int, long long)> dfs = [&](int u, int p, int h, long long dep) {
        int res = n + 1;
        mp[u][dep] = h;
        for (auto [v, ind] : g[u]) {
            if (v != p) {
                res = min(res, dfs(v, u, h + 1, dep + L[ind]));
                if (mp[u].size() > mp[v].size()) {
                    mp[u].swap(mp[v]);
                }
                for (auto [x, y] : mp[v]) {
                    if (mp[u].count(k + 2 * dep - x)) {
                        res = min(res, y + mp[u][k + 2 * dep - x] - 2 * h);
                    }
                }
                for (auto [x, y] : mp[v]) {
                    if (!mp[u].count(x)) {
                        mp[u][x] = y;
                    } else {
                        mp[u][x] = min(mp[u][x], y);
                    }
                }
            }
        }
        return res;
    };
    auto res = dfs(0, 0, 0, 0);
    return res == n + 1 ? -1 : res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 668 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 660 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 668 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 660 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 4 ms 1924 KB Output is correct
22 Correct 4 ms 2140 KB Output is correct
23 Correct 8 ms 3932 KB Output is correct
24 Correct 6 ms 3160 KB Output is correct
25 Correct 7 ms 3164 KB Output is correct
26 Correct 5 ms 2500 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 6 ms 3288 KB Output is correct
29 Correct 6 ms 3116 KB Output is correct
30 Correct 5 ms 2140 KB Output is correct
31 Correct 6 ms 2652 KB Output is correct
32 Correct 6 ms 2848 KB Output is correct
33 Correct 4 ms 2312 KB Output is correct
34 Correct 19 ms 8556 KB Output is correct
35 Correct 18 ms 10548 KB Output is correct
36 Correct 22 ms 11864 KB Output is correct
37 Correct 10 ms 6236 KB Output is correct
38 Correct 7 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 668 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 660 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 205 ms 76368 KB Output is correct
20 Correct 223 ms 76992 KB Output is correct
21 Correct 202 ms 67836 KB Output is correct
22 Correct 237 ms 78928 KB Output is correct
23 Correct 197 ms 68176 KB Output is correct
24 Correct 193 ms 70428 KB Output is correct
25 Runtime error 320 ms 262144 KB Execution killed with signal 9
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 668 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 660 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 4 ms 1924 KB Output is correct
22 Correct 4 ms 2140 KB Output is correct
23 Correct 8 ms 3932 KB Output is correct
24 Correct 6 ms 3160 KB Output is correct
25 Correct 7 ms 3164 KB Output is correct
26 Correct 5 ms 2500 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 6 ms 3288 KB Output is correct
29 Correct 6 ms 3116 KB Output is correct
30 Correct 5 ms 2140 KB Output is correct
31 Correct 6 ms 2652 KB Output is correct
32 Correct 6 ms 2848 KB Output is correct
33 Correct 4 ms 2312 KB Output is correct
34 Correct 19 ms 8556 KB Output is correct
35 Correct 18 ms 10548 KB Output is correct
36 Correct 22 ms 11864 KB Output is correct
37 Correct 10 ms 6236 KB Output is correct
38 Correct 7 ms 4444 KB Output is correct
39 Correct 205 ms 76368 KB Output is correct
40 Correct 223 ms 76992 KB Output is correct
41 Correct 202 ms 67836 KB Output is correct
42 Correct 237 ms 78928 KB Output is correct
43 Correct 197 ms 68176 KB Output is correct
44 Correct 193 ms 70428 KB Output is correct
45 Runtime error 320 ms 262144 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -