# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
388595 | mariowong | Crocodile's Underground City (IOI11_crocodile) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
struct edge{
long long node,w;
}nw,now;
long long ans;
vector <edge> e[100005];
priority_queue <pair<long long,long long> > q;
bool vis[100005][5];
long long travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for (int i=0;i<M;i++){
now.w=L[i];
now.node=R[i][0]; e[R[i][1]].push_back(now);
nwo.node=R[i][1]; e[R[i][0]].push_back(now);
}
for (int i=0;i<K;i++){
q.push(make_pair(0,P[i]));
q.push(make_pair(0,P[i]));
}
while (!q.empty()){
now.w=-q.front().first; now.node=q.front().second;
if (!vis[now.node][0])
vis[now.node][0]=true;
else
if (!vis[now.node][1]){
vis[now.node][1]=true;
if (now.node == 0) ans=now.w;
for (int i=0;i<e[now.node].size();i++){
if (!vis[e[now.node][i].node][1])
q.push(make_pair(-(now.w+e[now.node][i].w),e[now.node][i].node));
}
}
}
return ans;
}