This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cyberland.h"
#include <bits/stdc++.h>
template <typename T>
using PQG = std::priority_queue<T, std::vector<T>, std::greater<T>>;
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
std::vector<std::vector<std::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);
}
PQG<std::pair<double, int>> pq;
double ans = 1e18;
std::vector<double> dp(N, 1e18);
pq.emplace(0, 0);
dp[0] = 0;
while (pq.size()) {
auto [d, u] = pq.top();
pq.pop();
if (d > dp[u]) continue;
for (auto [v, w] : adj[u]) {
auto nd = dp[v] + w;
if (nd < dp[v]) {
dp[v] = nd;
pq.emplace(nd, v);
}
}
}
ans = dp[H];
return (ans < 1e18 ? ans : -1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |