#include "crocodile.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
vector<ll>komsu[N],cos[N];
for(int i=0;i<M;i++){
komsu[R[i][0]].pb(R[i][1]);
komsu[R[i][1]].pb(R[i][0]);
cos[R[i][0]].pb(L[i]);
cos[R[i][1]].pb(L[i]);
}
priority_queue<pair<ll,int>>pq;
int say[N];for(int &x:say)x=0;
for(int i=0;i<K;i++){
say[P[i]]=1;
pq.push({0,P[i]});
}
while(pq.size()){
ll sum=pq.top().first;
int pos=pq.top().second;
pq.pop();
if(say[pos]==2)continue;
say[pos]++;
if(say[pos]==1)continue;
if(!pos){
return sum;
}
for(int i=0;i<ll(komsu[pos].size());i++){
pq.push({sum+cos[pos][i],komsu[pos][i]});
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |