Submission #1010278

# Submission time Handle Problem Language Result Execution time Memory
1010278 2024-06-28T16:15:25 Z overwatch9 Shortcut (IOI16_shortcut) C++17
0 / 100
2000 ms 348 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector <vector <pair <int, int>>> adj;
int N;
pair <int, ll> dijkstra(int s) {
    priority_queue <pair <ll, int>> pq;
    vector <ll> dis(N+1, 1e17);
    vector <bool> processed(N+1);
    dis[s] = 0;
    pq.push({0, s});
    int node = 0;
    ll mx = 0;
    while (!pq.empty()) {
        s = pq.top().second;
        pq.pop();
        if (processed[s])
            continue;
        processed[s] = true;
        if (mx < dis[s]) {
            mx = dis[s];
            node = s;
        }
        for (auto i : adj[s]) {
            if (dis[i.first] > dis[s] + i.second) {
                dis[i.first] = dis[s] + i.second;
                pq.push({-dis[i.first], i.first});
            }
        }
    }
    return {node, mx};
}
ll find_shortcut(int n, vector<int> l, vector<int> d, int c)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    adj.resize(n * 2 + 5);
    for (int i = 0; i+1 < n; i++) {
        adj[i].push_back({i+1, l[i]});
        adj[i+1].push_back({i, l[i]});
    }
    int ogn = n;
    for (int i = 0; i < ogn; i++) {
        if (d[i] == 0)
            continue;
        adj[i].push_back({n, d[i]});
        adj[n].push_back({i, d[i]});
        n++;
    }
    N = n;
    pair <int, ll> res;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        res = dijkstra(i);
        res = dijkstra(res.first);
        ans = max(ans, res.second);
    }
    for (int i = 0; i < ogn; i++) {
        for (int j = i+1; j < ogn; j++) {
            adj[i].push_back({j, c});
            adj[j].push_back({i, c});
            ll tp = 0;
            for (int k = 0; k < n; k++) {
                res = dijkstra(k);
                res = dijkstra(res.first);
                tp = max(tp, res.second);
            }
            ans = min(ans, tp);
            adj[i].pop_back();
            adj[j].pop_back();
        }
    }
    return ans;
}
// int main() {
//     int n;
//     cin >> n;
//     vector <int> l(n), d(n);
//     for (int i = 0; i < n-1; i++)
//         cin >> l[i];
//     for (int i = 0; i < n; i++)
//         cin >> d[i];
//     int c;
//     cin >> c;
//     cout << find_shortcut(n, l, d, c) << '\n';
// }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 1 ms 348 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 0 ms 344 KB n = 2, 62 is a correct answer
6 Correct 0 ms 348 KB n = 2, 3 is a correct answer
7 Correct 1 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 0 ms 348 KB n = 2, 3 is a correct answer
10 Correct 0 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 348 KB n = 5, 4000000000 is a correct answer
17 Correct 1 ms 344 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 348 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 348 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 348 KB n = 5, 12 is a correct answer
21 Correct 0 ms 348 KB n = 5, 25 is a correct answer
22 Correct 0 ms 348 KB n = 2, 122 is a correct answer
23 Correct 1 ms 348 KB n = 10, 117 is a correct answer
24 Correct 1 ms 348 KB n = 10, 336 is a correct answer
25 Correct 1 ms 344 KB n = 10, 438 is a correct answer
26 Correct 1 ms 348 KB n = 10, 206 is a correct answer
27 Correct 1 ms 344 KB n = 10, 636 is a correct answer
28 Correct 0 ms 348 KB n = 4, 2399 is a correct answer
29 Correct 1 ms 348 KB n = 10, 10992 is a correct answer
30 Correct 1 ms 348 KB n = 10, 3112 is a correct answer
31 Execution timed out 2093 ms 348 KB Time limit exceeded
32 Halted 0 ms 0 KB -