답안 #1113111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113111 2024-11-15T19:07:56 Z ortsac 사이버랜드 (APIO23_cyberland) C++17
15 / 100
198 ms 26440 KB
#include "cyberland.h"
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define pii pair<long long, long long>
#define fr first
#define se second

double INF = 1e18;

double solve(int32_t N, int32_t M, int32_t K, int32_t H, vector<int32_t> x, vector<int32_t> y, vector<int32_t> c, vector<int32_t> arr) {
    int n, m, k, h;
    n = N;
    m = M;
    k = K;
    h = H;
    vector<vector<pii>> adj(n);
    for (int i = 0; i < m; i++) {
        int a = x[i], b = y[i], co = c[i];
        adj[a].push_back({b, co});
        adj[b].push_back({a, co});
    }
    vector<vector<bool>> prop(n, vector<bool>(31));
    vector<vector<double>> dist(n, vector<double>(31, INF));
    dist[0][0] = 0;
    priority_queue<pair<double, pii>> pq;
    pq.push({0, {0, 0}});
    while (!pq.empty()) {
        auto [u, qtd] = pq.top().se;
        pq.pop();
        if (prop[u][qtd]) continue;
        prop[u][qtd] = 1;
        for (auto [v, cost] : adj[u]) {
            // propaga sem aumentar o k
            if (!prop[v][qtd]) {
                double novo = (((double)cost) + dist[u][qtd]);
                if (arr[v] == 0) novo = 0;
                if (novo < dist[v][qtd]) {
                    dist[v][qtd] = novo;
                    pq.push({-novo, {v, qtd}});
                }
            }
            if ((qtd < k) && (arr[v] == 2) && (!prop[v][qtd + 1])) {
                double novo = (((double)cost) + dist[u][qtd]) / 2.0;
                if (novo < dist[v][qtd + 1]) {
                    dist[v][qtd + 1] = novo;
                    pq.push({-novo, {v, qtd + 1}});
                }
            }
        }
    }
    double ans = INF;
    for (int i = 0; i <= k; i++) {
        ans = min(ans, dist[h][i]);
    }
    if (ans == INF) return -1;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 584 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 848 KB Correct.
2 Correct 32 ms 948 KB Correct.
3 Correct 27 ms 848 KB Correct.
4 Correct 32 ms 1044 KB Correct.
5 Correct 36 ms 972 KB Correct.
6 Correct 29 ms 4876 KB Correct.
7 Correct 35 ms 4848 KB Correct.
8 Correct 21 ms 9296 KB Correct.
9 Correct 27 ms 336 KB Correct.
10 Correct 26 ms 336 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 904 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 26440 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 872 KB Correct.
2 Correct 27 ms 848 KB Correct.
3 Correct 27 ms 968 KB Correct.
4 Correct 27 ms 4524 KB Correct.
5 Correct 24 ms 592 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 848 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 198 ms 1332 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1016 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -