Submission #1060966

# Submission time Handle Problem Language Result Execution time Memory
1060966 2024-08-16T05:04:39 Z stdfloat Cyberland (APIO23_cyberland) C++17
8 / 100
23 ms 5720 KB
#include <bits/stdc++.h>
#include "cyberland.h"
// #include "stub.cpp"
using namespace std;

using ll = long long;

#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();

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

    if (!vis0[H]) {
        assert(false);
        return -1;
    }

    vector<ll> dis(n, LLONG_MAX);
    priority_queue<pair<ll, int>> pq;
    dis[H] = 0; pq.push({0, H});
    while (!pq.empty()) {
        auto [d, x] = pq.top(); d = -d; pq.pop();
    
        if (d != dis[x]) continue;

        for (auto [i, w] : E[x]) {
            if (d + w < dis[i]) {
                dis[i] = d + w;
                pq.push({-dis[i], i});
            }
        }
    }

    ll ans = dis[0];
    for (int i = 1; i < n; i++) {
        if (!a[i] && vis0[i]) ans = min(ans, dis[i]);
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 604 KB Correct.
2 Correct 19 ms 600 KB Correct.
3 Correct 19 ms 604 KB Correct.
4 Correct 23 ms 348 KB Correct.
5 Correct 19 ms 604 KB Correct.
6 Correct 17 ms 1372 KB Correct.
7 Correct 20 ms 1372 KB Correct.
8 Correct 10 ms 2464 KB Correct.
9 Correct 17 ms 348 KB Correct.
10 Correct 16 ms 348 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 556 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 5720 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -