Submission #1062698

# Submission time Handle Problem Language Result Execution time Memory
1062698 2024-08-17T09:54:05 Z stdfloat Cyberland (APIO23_cyberland) C++17
49 / 100
1333 ms 169380 KB
#include <bits/stdc++.h>
#include "cyberland.h"
// #include "stub.cpp"
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>((int)2e2 + 1, 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;

        if (x == H) return d;
    
        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 < (int)2e2 && (d + w) / 2 < dis[i][y + 1]) {
                dis[i][y + 1] = (d + w) / 2;
                pq.push({-dis[i][y + 1], {i, y + 1}});
            }
        }
    }

    assert(false);
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 600 KB Correct.
2 Correct 16 ms 600 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2164 KB Correct.
2 Correct 40 ms 1992 KB Correct.
3 Correct 39 ms 2212 KB Correct.
4 Correct 39 ms 2152 KB Correct.
5 Correct 43 ms 2172 KB Correct.
6 Correct 33 ms 17008 KB Correct.
7 Correct 46 ms 16712 KB Correct.
8 Correct 25 ms 33716 KB Correct.
9 Correct 23 ms 664 KB Correct.
10 Correct 22 ms 684 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2132 KB Correct.
2 Correct 42 ms 2036 KB Correct.
3 Correct 37 ms 2180 KB Correct.
4 Correct 27 ms 668 KB Correct.
5 Correct 25 ms 604 KB Correct.
6 Correct 10 ms 14172 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1187 ms 117172 KB Correct.
2 Incorrect 1333 ms 3964 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2124 KB Correct.
2 Correct 25 ms 2100 KB Correct.
3 Correct 34 ms 2024 KB Correct.
4 Correct 29 ms 16732 KB Correct.
5 Correct 20 ms 644 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2036 KB Correct.
2 Correct 21 ms 1884 KB Correct.
3 Correct 27 ms 7312 KB Correct.
4 Correct 19 ms 10208 KB Correct.
5 Correct 25 ms 672 KB Correct.
6 Correct 25 ms 2044 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 944 ms 8840 KB Correct.
2 Correct 117 ms 10272 KB Correct.
3 Incorrect 152 ms 164876 KB Wrong Answer.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 951 ms 8864 KB Correct.
2 Correct 116 ms 9832 KB Correct.
3 Correct 86 ms 169380 KB Correct.
4 Incorrect 790 ms 15356 KB Wrong Answer.
5 Halted 0 ms 0 KB -