답안 #1062691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062691 2024-08-17T09:53:02 Z stdfloat 사이버랜드 (APIO23_cyberland) C++17
49 / 100
3000 ms 404308 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)5e2 + 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)5e2 && (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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 600 KB Correct.
2 Correct 21 ms 604 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 4596 KB Correct.
2 Correct 73 ms 4500 KB Correct.
3 Correct 69 ms 4572 KB Correct.
4 Correct 72 ms 4560 KB Correct.
5 Correct 71 ms 4624 KB Correct.
6 Correct 73 ms 39844 KB Correct.
7 Correct 95 ms 39140 KB Correct.
8 Correct 46 ms 79656 KB Correct.
9 Correct 50 ms 1168 KB Correct.
10 Correct 47 ms 888 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 4524 KB Correct.
2 Correct 71 ms 4652 KB Correct.
3 Correct 66 ms 4584 KB Correct.
4 Correct 61 ms 1736 KB Correct.
5 Correct 51 ms 904 KB Correct.
6 Correct 16 ms 32956 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3063 ms 270564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 4444 KB Correct.
2 Correct 40 ms 4352 KB Correct.
3 Correct 43 ms 4372 KB Correct.
4 Correct 49 ms 39476 KB Correct.
5 Correct 25 ms 876 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 4424 KB Correct.
2 Correct 31 ms 4152 KB Correct.
3 Correct 28 ms 7252 KB Correct.
4 Correct 26 ms 23652 KB Correct.
5 Correct 30 ms 884 KB Correct.
6 Correct 40 ms 4360 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 2558 ms 28524 KB Correct.
2 Correct 311 ms 27704 KB Correct.
3 Incorrect 367 ms 392420 KB Wrong Answer.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2568 ms 27208 KB Correct.
2 Correct 318 ms 27260 KB Correct.
3 Correct 214 ms 404308 KB Correct.
4 Incorrect 2238 ms 34760 KB Wrong Answer.
5 Halted 0 ms 0 KB -