This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |