Submission #1253509

#TimeUsernameProblemLanguageResultExecution timeMemory
1253509anfiCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const double INF = 1e18;

double solve(int N, int M, int K, int H,
             const vector<int>& x,
             const vector<int>& y,
             const vector<int>& c,
             const vector<int>& arr) {
    vector<vector<pair<int,int>>> adj(N);
    for (int i = 0; i < M; i++) {
        int u = x[i], v = y[i], w = c[i];
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }
    vector<vector<double>> dist(N, vector<double>(K+1, INF));
    deque<pair<int,int>> dq;
    dist[0][0] = 0.0;
    dq.emplace_front(0, 0);

    while (!dq.empty()) {
        auto [u, used] = dq.front(); dq.pop_front();
        double d = dist[u][used];

        for (auto [v, w] : adj[u]) {
            double nd = d + w;
            int nk = used;
            if (arr[v] == 0) {
                nd = 0.0;
            }
            else if (arr[v] == 2 && used < K) {
                nd *= 0.5;
                nk++;
            }

            if (nd + 1e-12 < dist[v][nk]) {
                double old = dist[v][nk];
                dist[v][nk] = nd;
                if (nd < d) dq.emplace_front(v, nk);
                else       dq.emplace_back(v, nk);
            }
        }
    }

    double ans = INF;
    for (int k = 0; k <= K; k++) {
        ans = min(ans, dist[H][k]);
    }
    return (ans >= INF/2 ? -1.0 : ans);
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccmhV1d6.o: in function `main':
grader.cpp:(.text.startup+0x71e): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status