| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 706699 | Trisanu_Das | 관광 (NOI14_sightseeing) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int v, e, q; cin >> v >> e >> q;
vector<pair<int, int> > adj[v + 1];
for(int e = 1; e <= E; 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> > tbv;
vector<int> dp(v + 1, 0);
dp[1] = 1e9 + 1;
tbv.insert({dp[1], 1});
while(!tbv.empty()){
int u = tbv.rbegin()->second;
tbv.erase(*tbv.rbegin());
for(pair<int, int> v : adj[u]) {
int quality = min(v.first, dp[u]);
if(quality > dp[v.second]) {
dp[v.second] = quality;
tbv.insert({dp[v.second], v.second});
}
}
}
while(q--){
int X; cin >> X; cout << dp[X] << '\n';
}
}
