Submission #492908

# Submission time Handle Problem Language Result Execution time Memory
492908 2021-12-09T17:21:29 Z dxz05 Shortcut (IOI16_shortcut) C++14
0 / 100
16 ms 23784 KB
#include "shortcut.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector<pair<int, int>> g[1000010];
ll diam(int n, int c, vector<int> &d, int x, int y){
    g[x].emplace_back(y, c);
    g[y].emplace_back(x, c);

    ll res = 0;
    for (int i = 0; i < n; i++){
        priority_queue<pair<ll, int>> q;
        q.push({0, i});

        vector<bool> processed(n, false);
        vector<ll> dist(n, 1e9);
        dist[i] = 0;

        while (!q.empty()){
            int v = q.top().second; q.pop();
            if (processed[v]) continue;
            processed[v] = true;

            for (auto edge : g[v]){
                int u = edge.first, w = edge.second;
                if (dist[u] > dist[v] + w){
                    dist[u] = dist[v] + w;
                    q.push({-dist[u], u});
                }
            }
        }

        for (int j = 0; j < n; j++){
            if (j != i) res = max(res, d[i] + dist[j] + d[j]);
        }
    }

    g[x].pop_back();
    g[y].pop_back();

    return res;
}

long long find_shortcut(int n, vector<int> l, vector<int> d, int c){
    for (int i = 0; i < n - 1; i++){
        g[i].emplace_back(i + 1, l[i]);
        g[i + 1].emplace_back(i, l[i]);
    }

    ll res = 1e18;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            res = min(res, diam(n, c, d, i, j));
        }
    }

    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB n = 4, 80 is a correct answer
2 Correct 12 ms 23760 KB n = 9, 110 is a correct answer
3 Correct 12 ms 23756 KB n = 4, 21 is a correct answer
4 Correct 12 ms 23772 KB n = 3, 4 is a correct answer
5 Correct 12 ms 23756 KB n = 2, 62 is a correct answer
6 Correct 12 ms 23708 KB n = 2, 3 is a correct answer
7 Correct 12 ms 23784 KB n = 3, 29 is a correct answer
8 Correct 12 ms 23688 KB n = 2, 3 is a correct answer
9 Correct 12 ms 23676 KB n = 2, 3 is a correct answer
10 Correct 12 ms 23748 KB n = 2, 2000000001 is a correct answer
11 Correct 13 ms 23740 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23776 KB n = 3, 3000000000 is a correct answer
13 Correct 12 ms 23756 KB n = 3, 3000000000 is a correct answer
14 Incorrect 13 ms 23756 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -