Submission #658320

#TimeUsernameProblemLanguageResultExecution timeMemory
658320Leo121Crocodile's Underground City (IOI11_crocodile)C++14
0 / 100
13 ms23808 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 [1000000]; 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<N; 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++){ for (auto e : grafo[P[i]]){ datos.push(e); visitados[e.a]=1; } } NODO u,v; while(!datos.empty()){ u=datos.top(); datos.pop(); for(auto e: grafo[u.a]){ if(visitados[e.a]==0){ estado[e.a]++; if(estado[e.a]>1){ visitados[e.a]=1; distancias[e.a]=u.b+e.b; datos.push({e.a,distancias[e.a]}); } } } } N=distancias[0]; return N; }

Compilation message (stderr)

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