Submission #698567

#TimeUsernameProblemLanguageResultExecution timeMemory
698567blueSightseeing (NOI14_sightseeing)C++17
25 / 25
3343 ms262144 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using pii = pair<int, int>; using vpii = vector<pii>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int V, E, Q; cin >> V >> E >> Q; vpii edge[1 + V]; for(int e = 1; e <= E; e++) { int u, v, w; cin >> u >> v >> w; edge[u].push_back({w, v}); edge[v].push_back({w, u}); } set<pii> tbv; vi dp(1 + V, 0); dp[1] = 1'000'000'001; tbv.insert({dp[1], 1}); while(!tbv.empty()) { int u = tbv.rbegin()->second; tbv.erase(*tbv.rbegin()); for(pii vp : edge[u]) { int nw = min(vp.first, dp[u]); if(nw > dp[vp.second]) { dp[vp.second] = nw; tbv.insert({dp[vp.second], vp.second}); } } } for(int q = 1; q <= Q; q++) { int X; cin >> X; cout << dp[X] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...