Submission #1062694

# Submission time Handle Problem Language Result Execution time Memory
1062694 2024-08-17T09:53:25 Z stdfloat Cyberland (APIO23_cyberland) C++17
49 / 100
2838 ms 326048 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)4e2 + 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)4e2 && (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 21 ms 604 KB Correct.
2 Correct 22 ms 600 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 57 ms 3736 KB Correct.
2 Correct 72 ms 3904 KB Correct.
3 Correct 62 ms 3648 KB Correct.
4 Correct 60 ms 3968 KB Correct.
5 Correct 59 ms 3988 KB Correct.
6 Correct 64 ms 32292 KB Correct.
7 Correct 109 ms 31752 KB Correct.
8 Correct 34 ms 64336 KB Correct.
9 Correct 39 ms 812 KB Correct.
10 Correct 39 ms 1056 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3572 KB Correct.
2 Correct 83 ms 3812 KB Correct.
3 Correct 56 ms 3744 KB Correct.
4 Correct 44 ms 812 KB Correct.
5 Correct 43 ms 796 KB Correct.
6 Correct 13 ms 26716 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 2547 ms 222868 KB Correct.
2 Incorrect 2838 ms 9124 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 3704 KB Correct.
2 Correct 36 ms 3436 KB Correct.
3 Correct 43 ms 3460 KB Correct.
4 Correct 64 ms 31888 KB Correct.
5 Correct 36 ms 792 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3548 KB Correct.
2 Correct 28 ms 3420 KB Correct.
3 Correct 32 ms 7252 KB Correct.
4 Correct 29 ms 19340 KB Correct.
5 Correct 27 ms 1016 KB Correct.
6 Correct 36 ms 3600 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 2129 ms 18168 KB Correct.
2 Correct 234 ms 20220 KB Correct.
3 Incorrect 288 ms 317236 KB Wrong Answer.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2057 ms 17304 KB Correct.
2 Correct 235 ms 19996 KB Correct.
3 Correct 159 ms 326048 KB Correct.
4 Incorrect 1720 ms 29764 KB Wrong Answer.
5 Halted 0 ms 0 KB -