Submission #1062607

# Submission time Handle Problem Language Result Execution time Memory
1062607 2024-08-17T09:02:05 Z stdfloat Cyberland (APIO23_cyberland) C++17
44 / 100
718 ms 47020 KB
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;

#define ff  first
#define ss  second
#define pii pair<int, int>

double solve(int n, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> a) {
    vector<pii> E[n];
    for (int i = 0; i < M; i++) {
        E[X[i]].push_back({Y[i], C[i]});
        E[Y[i]].push_back({X[i], C[i]});
    }

    queue<int> q;
    vector<bool> vis0(n);
    q.push(0); vis0[0] = true;
    while (!q.empty()) {
        int x = q.front(); q.pop();

        if (x == H) continue;

        for (auto [i, w] : E[x]) {
            if (!vis0[i]) {
                q.push(i);
                vis0[i] = true;
            }
        }
    }

    if (!vis0[H]) return -1;

    vector<vector<double>> dis(n, vector<double>(71, 1e18));
    priority_queue<pair<double, pii>> pq;
    for (int i = 0; i < n; i++) {
        if (!i || (!a[i] && vis0[i])) {
            dis[i][0] = 0;
            pq.push({0, {i, 0}});
        }
    }
    while (!pq.empty()) {
        double d = pq.top().ff; d = -d;
        auto [x, y] = pq.top().ss; pq.pop();
    
        if (d != dis[x][y]) continue;
    
        for (auto [i, w] : E[x]) {
            if (!a[i]) continue;

            if (d + w < dis[i][y]) {
                dis[i][y] = d + w;
                pq.push({-dis[i][y], {i, y}});
            }
            if (a[i] == 2 && y < 70 && (d + w) / 2 < dis[i][y + 1]) {
                dis[i][y + 1] = (d + w) / 2;
                pq.push({-dis[i][y + 1], {i, y + 1}});
            }
        }
    }

    return *min_element(dis[H].begin(), dis[H].end());
}
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 852 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1884 KB Correct.
2 Correct 22 ms 2140 KB Correct.
3 Correct 22 ms 2128 KB Correct.
4 Correct 25 ms 2132 KB Correct.
5 Correct 24 ms 2096 KB Correct.
6 Correct 25 ms 7820 KB Correct.
7 Correct 29 ms 7720 KB Correct.
8 Correct 15 ms 14168 KB Correct.
9 Correct 21 ms 1372 KB Correct.
10 Correct 21 ms 1368 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1968 KB Correct.
2 Correct 24 ms 2092 KB Correct.
3 Correct 26 ms 2032 KB Correct.
4 Correct 28 ms 1324 KB Correct.
5 Correct 22 ms 1396 KB Correct.
6 Correct 10 ms 6224 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 538 ms 47020 KB Correct.
2 Incorrect 718 ms 2948 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1936 KB Correct.
2 Correct 20 ms 2000 KB Correct.
3 Correct 20 ms 2016 KB Correct.
4 Correct 21 ms 7512 KB Correct.
5 Correct 17 ms 1372 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2116 KB Correct.
2 Correct 20 ms 1844 KB Correct.
3 Correct 29 ms 9052 KB Correct.
4 Correct 16 ms 4952 KB Correct.
5 Correct 19 ms 1644 KB Correct.
6 Correct 21 ms 1924 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 622 ms 4852 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 628 ms 4756 KB Wrong Answer.
2 Halted 0 ms 0 KB -