| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 600296 | shezitt | Crocodile's Underground City (IOI11_crocodile) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << x << endl;
#define raya cout << "===========================" << endl;
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const int N = 1e5+5;
int n, m;
int vis[N];
vector<pair<int,int>> g[N];
int travel_plan(int nn, int mm, int R[][2], int L[], int K, int P[]){
n = nn;
m = mm;
for(int i=0; i<m; ++i){
g[R[i][0]].push_back({R[i][1], L[i]});
g[R[i][1]].push_back({R[i][0], L[i]});
}
for(int i=0; i<N; ++i){
t[i] = INF;
}
priority_queue<pair<ll,int>> pq;
for(int i=0; i<K; ++i){
pq.push({0, P[i]});
t[P[i]] = 0;
vis[P[i]] = 1;
}
while(!pq.empty()){
auto w = -pq.top().first; auto u = pq.top().second;
pq.pop();
if(!vis[u]){
vis[u] = 1;
continue;
}
if(vis[u] == 2){
continue;
}
if(u == 0){
return w;
}
vis[u] = 2;
for(auto v : g[u]){
if(vis[v.first] == 2){
continue;
}
pq.push({-(w+v.second), v.first});
}
}
assert(0);
return -1;
}
