Submission #124510

#TimeUsernameProblemLanguageResultExecution timeMemory
124510johuthaSightseeing (NOI14_sightseeing)C++14
15 / 25
3529 ms124044 KiB
#include <vector> #include <iostream> #include <queue> #define int int64_t using namespace std; signed main() { int v, e, q; cin >> v >> e >> q; vector<vector<pair<int,int>>> adjlist(v); for (int z = 0; z < e; z++) { int st, en, qu; cin >> st >> en >> qu; st--; en--; adjlist[st].push_back({en, qu}); adjlist[en].push_back({st, qu}); } vector<int> visited(v, -1); visited[0] = 1e12; priority_queue<pair<int,int>> pq; pq.push({0, 0}); while (!pq.empty()) { int curr = pq.top().second; pq.pop(); for (auto p : adjlist[curr]) { int next = p.first; int quality = min(visited[curr], p.second); if (quality > visited[next]) { visited[next] = quality; pq.push({quality, next}); } } } for (int i = 0; i < q; i++) { int n; cin >> n; n--; cout << visited[n] << "\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...