Submission #1153153

#TimeUsernameProblemLanguageResultExecution timeMemory
1153153burgerguyCyberland (APIO23_cyberland)C++20
0 / 100
16 ms6728 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; 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) { vector<vector<pair<ll,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,ll>, vector<pair<ll,ll>>, greater<>> pq; pq.emplace(0, 0); vector<bool> vis(N); vector<ll> dist(N, INT_MAX); while(!pq.empty()) { ll curCountry = pq.top().second; ll curScore = pq.top().first; pq.pop(); if(vis[curCountry]) continue; vis[curCountry] = true; for(pair<ll,ll> u : adj[curCountry]) { ll newScore; if(arr[u.first] == 0) { newScore = 0; } else if(arr[u.first] == 1) { newScore = curScore + u.second; } if(newScore < dist[u.first]) { dist[u.first] = newScore; pq.emplace(newScore, u.first); } } } ll ans = 0; if(dist[H] == INT_MAX) ans = -1; else ans = dist[H]; return ans; }
#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...