Submission #1062682

# Submission time Handle Problem Language Result Execution time Memory
1062682 2024-08-17T09:50:01 Z stdfloat Cyberland (APIO23_cyberland) C++17
49 / 100
433 ms 169444 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>(200, 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 < 70 && (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 15 ms 600 KB Correct.
2 Correct 24 ms 604 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2292 KB Correct.
2 Correct 40 ms 2080 KB Correct.
3 Correct 59 ms 2048 KB Correct.
4 Correct 38 ms 2092 KB Correct.
5 Correct 63 ms 2184 KB Correct.
6 Correct 33 ms 17000 KB Correct.
7 Correct 50 ms 16740 KB Correct.
8 Correct 24 ms 33624 KB Correct.
9 Correct 31 ms 668 KB Correct.
10 Correct 24 ms 656 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2276 KB Correct.
2 Correct 48 ms 2268 KB Correct.
3 Correct 57 ms 2088 KB Correct.
4 Correct 41 ms 668 KB Correct.
5 Correct 38 ms 604 KB Correct.
6 Correct 9 ms 14168 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 402 ms 103108 KB Correct.
2 Incorrect 433 ms 2872 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2124 KB Correct.
2 Correct 27 ms 1952 KB Correct.
3 Correct 25 ms 2056 KB Correct.
4 Correct 29 ms 16704 KB Correct.
5 Correct 17 ms 652 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2028 KB Correct.
2 Correct 21 ms 2000 KB Correct.
3 Correct 29 ms 7252 KB Correct.
4 Correct 20 ms 10208 KB Correct.
5 Correct 18 ms 664 KB Correct.
6 Correct 28 ms 1944 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 301 ms 4476 KB Correct.
2 Correct 39 ms 3568 KB Correct.
3 Incorrect 112 ms 162180 KB Wrong Answer.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 295 ms 4484 KB Correct.
2 Correct 39 ms 3568 KB Correct.
3 Correct 94 ms 169444 KB Correct.
4 Incorrect 253 ms 10964 KB Wrong Answer.
5 Halted 0 ms 0 KB -