Submission #706701

#TimeUsernameProblemLanguageResultExecution timeMemory
706701Trisanu_DasSightseeing (NOI14_sightseeing)C++17
25 / 25
3489 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int v, e, q; cin >> v >> e >> q; vector<pair<int, int> > adj[v + 1]; while(e--){ int u, v, w; cin >> u >> v >> w; adj[u].push_back({w, v}); adj[v].push_back({w, u}); } set<pair<int, int> > dij; vector<int> dp(v + 1, 0); dp[1] = 1e9 + 1; dij.insert({dp[1], 1}); while(!dij.empty()){ int u = dij.rbegin()->second; dij.erase(*dij.rbegin()); for(pair<int, int> vv : adj[u]) { int quality = min(vv.first, dp[u]); if(quality > dp[vv.second]) { dp[vv.second] = quality; dij.insert({dp[vv.second], vv.second}); } } } while(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...