#include "crocodile.h"
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
vector<long long int> distancia(N,1e9);
vector<vector<pair<long long int,long long int> > > conexiones(N,vector<pair<long long int,long long int> >());
for(long long int i=0;i<M;i++){
conexiones[R[i][0]].push_back(make_pair(L[i],R[i][1]));
conexiones[R[i][1]].push_back(make_pair(L[i],R[i][0]));
}
priority_queue <pair<long long int,long long int> > q;
for(int i=0;i<K;i++){
q.push(make_pair(0,P[i]));
distancia[P[i]]=0;
}
long long int nodo,coste;
while(!q.empty()){
nodo=q.top().second;
coste=-q.top().first;
q.pop();
if(coste>distancia[nodo])continue;
for(pair<long long int,long long int> con:conexiones[nodo]){
long long int arista=con.first;
long long int siguiente=con.second;
if(distancia[siguiente]>distancia[nodo]+arista){
distancia[siguiente]=distancia[nodo]+arista;
q.push(make_pair(-arista,siguiente));
}
}
}
return distancia[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |