Submission #917809

#TimeUsernameProblemLanguageResultExecution timeMemory
917809XXBabaProBerkayCyberland (APIO23_cyberland)C++17
15 / 100
28 ms6740 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second using ll = long long; 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, ll>>> adj(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]); } priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> PQ; vector<ll> dist(N, 1e18); dist[0] = 0; PQ.emplace(0, 0); while (!PQ.empty()) { auto [d, u] = PQ.top(); PQ.pop(); if (d != dist[u]) continue; ll t = (arr[u] == 0 ? 0 : dist[u]); for (pair<int, ll> i : adj[u]) { auto [v, w] = i; if (dist[v] > t + w) PQ.emplace(dist[v] = t + w, v); } } return (dist[H] == 1e18 ? -1.0 : double(dist[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...