Submission #367928

#TimeUsernameProblemLanguageResultExecution timeMemory
367928IwanttobreakfreeCrocodile's Underground City (IOI11_crocodile)C++17
0 / 100
1 ms364 KiB
#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<int> distancia(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])); } priority_queue <pair<int,int> > q; q.push(make_pair(0,0)); distancia[0]=0; int nodo,coste; while(!q.empty()){ nodo=q.top().second; coste=-q.top().first; q.pop(); if(coste>distancia[nodo])continue; 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(make_pair(-arista,siguiente)); } } } for(int i=0;i<K;i++){ if(distancia[P[i]]==1e9)continue; else maximo=max(maximo,distancia[P[i]]); } return maximo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...