Submission #1228020

#TimeUsernameProblemLanguageResultExecution timeMemory
1228020jfioashfn333Cyberland (APIO23_cyberland)C++20
15 / 100
23 ms5700 KiB
#include "cyberland.h" #include <vector> #include <queue> #include <limits> using namespace std; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { vector<vector<pair<int, int>>> g(N); for (int i = 0; i < M; i++) { g[x[i]].emplace_back(y[i], c[i]); g[y[i]].emplace_back(x[i], c[i]); } vector<double> d(N, 1e18); d[0] = 0; priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> q; q.emplace(0, 0); while (!q.empty()) { auto [w, u] = q.top(); q.pop(); if (w > d[u]) continue; for (auto [v, cost] : g[u]) { double nw = d[u] + cost; if (arr[v] == 0) nw = 0; if (nw < d[v]) { d[v] = nw; q.emplace(nw, v); } } } if (d[H] == 1e18) return -1; return d[H]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...