제출 #1153173

#제출 시각아이디문제언어결과실행 시간메모리
1153173burgerguy사이버랜드 (APIO23_cyberland)C++20
15 / 100
18 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, 1e16); dist[0] = 0; 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 = curScore + u.second; if(newScore < dist[u.first]) { dist[u.first] = newScore; pq.emplace(newScore, u.first); } } } double ans = 0; if(!vis[H]) 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...