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;
int main() {
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 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... |