# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
64722 | zetapi | 악어의 지하 도시 (IOI11_crocodile) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <crocodile.h>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
typedef pair<ll,ll> pii;
const ll MAX=1e6;
const ll INF=1e14;
vector<pii> vec[MAX];
ll mark[MAX],dp[MAX],mn[MAX];
ll travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int A=0;A<M;A++)
{
vec[R[A][0]].pb(mp(R[A][1],L[A]));
vec[R[A][1]].pb(mp(R[A][0],L[A]));
}
for(int A=0;A<N;A++)
{
mn[A]=-1;
dp[A]=-1;
}
priority_queue<pii,vector<pii>,greater<pii>> pq;
for(int A=0;A<K;A++)
{
dp[P[A]]=0;
mn[P[A]]=0;
pq.push(mp(0,P[A]));
}
while(!pq.empty())
{
pii cur=pq.top();
pq.pop();
if(cur.first>dp[cur.second])
continue;
for(auto A:vec[cur.second])
{
if(dp[A.first]==-1)
{
dp[A.first]=INF;
mn[A.first]=cur.first+A.second;
}
else if(cur.first+A.second<dp[A.first])
{
dp[A.first]=cur.first+A.second;
if(dp[A.first]<mn[A.first])
swap(dp[A.first],mn[A.first]);
pq.push(mp(dp[A.first],A.first));
}
}
}
assert(dp[0]<INF);
return (int)dp[0];
}
/*signed main()
{
ios_base::sync_with_stdio(false);
int R[][2]={{0,2},{0,3},{3,2},{2,1},{0,1},{0,4},{3,4}};
int L[]={4,3,2,10,100,7,9};
int P[]={1,3};
cout<<travel_plan(5,7,R,L,2,P);
return 0;
}*/