#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';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
4544 KB |
Output is correct |
2 |
Correct |
63 ms |
3740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3533 ms |
128560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |