Submission #1113108

# Submission time Handle Problem Language Result Execution time Memory
1113108 2024-11-15T18:56:14 Z ortsac Cyberland (APIO23_cyberland) C++17
0 / 100
122 ms 29000 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

const int MAXN = 1e5 + 10;
vector<int> t;
int n, m, k, h;
vector<pii> adj[MAXN];
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) {
    n = N;
    m = M;
    k = K;
    h = H;
    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 = (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 = (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;
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5200 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 6236 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5988 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 29000 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 6012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5968 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5672 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5712 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -