Submission #124522

#TimeUsernameProblemLanguageResultExecution timeMemory
124522TouubsSightseeing (NOI14_sightseeing)C++17
15 / 25
3601 ms92788 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int v, e, q; cin >> v >> e >> q; vector<vector<pair<int, int>>> graph(v+1); for (int i = 0; i < e; i++) { int a, b, qual; cin >> a >> b >> qual; graph[a].emplace_back(qual, b); graph[b].emplace_back(qual, a); } priority_queue<pair<int, int>> queue; queue.push(make_pair(1000000, 1)); vector<bool> visited(v + 1); vector<int> optimum(v + 1); while (!queue.empty()) { pair<int, int> pos = queue.top(); queue.pop(); if (visited[pos.second]) continue; visited[pos.second] = true; optimum[pos.second] = pos.first; for (pair<int, int> adj : graph[pos.second]) { queue.push(make_pair(min(pos.first, adj.first), adj.second)); } } for (int i = 0; i < q; i++) { int query; cin >> query; cout << optimum[query] << "\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...