Submission #170350

#TimeUsernameProblemLanguageResultExecution timeMemory
170350ngmhSightseeing (NOI14_sightseeing)C++11
15 / 25
3606 ms218580 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; int v, e, q, a, b, w, maxi[500001]; vector<pi> adjlist[500001]; priority_queue<pi> pq; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); memset(maxi, -1, sizeof(maxi)); cin >> v >> e >> q; for(int i = 0; i < e; i++){ cin >> a >> b >> w; adjlist[a].push_back(pi(b, w)); adjlist[b].push_back(pi(a, w)); } maxi[1] = INT_MAX; pq.push(pi(INT_MAX, 1)); while(!pq.empty()){ pi f = pq.top(); pq.pop(); for(vector<pi>::iterator it = adjlist[f.second].begin(); it != adjlist[f.second].end(); it++){ if(maxi[(*it).first] < min(f.first, (*it).second)){ maxi[(*it).first] = min(f.first, (*it).second); pq.push(pi(maxi[(*it).first], (*it).first)); } } } for(int i = 0; i < q; i++){ cin >> a; cout << maxi[a] << "\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...