# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367598 | Iwanttobreakfree | Crocodile's Underground City (IOI11_crocodile) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "crocodile.h"
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<int> distancia;
void Distra(vector<vector<pair<int,int> > >& conexiones){
priority_queue <pair<int,int> > q;
q.push(0,0);
distancia[0]=0;
int nodo,coste;
while(!q.empty()){
nodo=q.top().second;
q.pop();
for(pair<int,int> con:conexiones[nodo]){
int arista=-con.first;
int siguiente=con.second;
if(distancia[siguiente]>distancia[nodo]+arista){
distancia[siguiente]=distancia[nodo]+arista;
q.push(-arista,siguiente);
}
}
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
distancia.assign(N,1e9);
int maximo=0;
vector<vector<pair<int,int> > > conexiones(N,vector<pair<int,int> >());
for(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]));
}
Distra(conexiones);
for(int i=0;i<K;i++){
maximo=max(maximo,distancia[P[i]]);
}
return maximo;
}