Submission #659688

#TimeUsernameProblemLanguageResultExecution timeMemory
659688paulo_arCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
626 ms72432 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; struct NODO { int a,b; const bool operator< (const NODO &otro)const{ return b>otro.b; } }; vector <NODO> grafo [1000005]; int visitados [100005]; int estado [100005]; int distancias [100005]; priority_queue<NODO> datos; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ for(int i=0; i<M; i++){ grafo[R[i][0]].push_back({R[i][1],L[i]}); grafo[R[i][1]].push_back({R[i][0],L[i]}); } for(int i=0; i<K; i++){ visitados[P[i]]=1; for (auto e : grafo[P[i]]){ datos.push(e); } } NODO u,v; while(!datos.empty()){ u=datos.top(); datos.pop(); // cout<<u.a<<" "<<u.b<<"\n"; estado[u.a]++; if(estado[u.a]>1){ if(visitados[u.a]==0){ visitados[u.a]=1; distancias[u.a]=u.b; for(auto e: grafo[u.a]){ if(visitados[e.a]==0){ datos.push({e.a,u.b+e.b}); } } } } /* for(int i=0; i<=N; i++){ cout<<distancias[i]<<" "; } cout<<"\n";*/ } N=distancias[0]; return N; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:39:10: warning: unused variable 'v' [-Wunused-variable]
   39 |   NODO u,v;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...