Submission #1253508

#TimeUsernameProblemLanguageResultExecution timeMemory
1253508anfiCyberland (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); adj.reserve(N); for(int i = 0; i < M; i++){ adj[x[i]].emplace_back(y[i], c[i]); adj[y[i]].emplace_back(x[i], c[i]); } vector<vector<double>> dist(N, vector<double>(K+1, INF)); dist[0][0] = 0.0; using State = pair<double, pair<int,int>>; priority_queue<State, vector<State>, greater<State>> pq; pq.push({0.0, {0, 0}}); while(!pq.empty()){ auto [d, uc] = pq.top(); pq.pop(); int u = uc.first, used = uc.second; if (d > dist[u][used]) continue; 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 = used + 1; } if (nd + 1e-12 < dist[v][nk]) { dist[v][nk] = nd; pq.push({nd, {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/ccDTjsnt.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