답안 #1062665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062665 2024-08-17T09:41:15 Z stdfloat 사이버랜드 (APIO23_cyberland) C++17
49 / 100
411 ms 93780 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>(100, 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}});
            }
        }
    }
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 860 KB Correct.
2 Correct 13 ms 860 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2140 KB Correct.
2 Correct 24 ms 2456 KB Correct.
3 Correct 20 ms 2364 KB Correct.
4 Correct 24 ms 2328 KB Correct.
5 Correct 24 ms 2404 KB Correct.
6 Correct 24 ms 10044 KB Correct.
7 Correct 27 ms 9832 KB Correct.
8 Correct 17 ms 18780 KB Correct.
9 Correct 19 ms 1372 KB Correct.
10 Correct 19 ms 1372 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2256 KB Correct.
2 Correct 28 ms 2152 KB Correct.
3 Correct 25 ms 2168 KB Correct.
4 Correct 24 ms 1352 KB Correct.
5 Correct 26 ms 1520 KB Correct.
6 Correct 8 ms 8024 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 402 ms 59128 KB Correct.
2 Incorrect 411 ms 3000 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1928 KB Correct.
2 Correct 19 ms 2376 KB Correct.
3 Correct 20 ms 2128 KB Correct.
4 Correct 25 ms 9564 KB Correct.
5 Correct 17 ms 1368 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2212 KB Correct.
2 Correct 18 ms 2080 KB Correct.
3 Correct 51 ms 9092 KB Correct.
4 Correct 14 ms 6456 KB Correct.
5 Correct 18 ms 1368 KB Correct.
6 Correct 21 ms 2132 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 4916 KB Correct.
2 Correct 39 ms 4156 KB Correct.
3 Incorrect 82 ms 90348 KB Wrong Answer.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 4852 KB Correct.
2 Correct 41 ms 4156 KB Correct.
3 Correct 78 ms 93780 KB Correct.
4 Incorrect 228 ms 8436 KB Wrong Answer.
5 Halted 0 ms 0 KB -