Submission #410845

#TimeUsernameProblemLanguageResultExecution timeMemory
410845AlexRex0Cave (IOI13_cave)C++14
100 / 100
456 ms496 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; bool visitado[5002]; int posiciones[5002]; int S[5002]; int prueba(int ini, int n){ for(int i = 0; i < n; ++i){ if(!visitado[i]){ S[i] = 0; } } if(tryCombination(S) != ini){ return 1; } return 2; } void bs(int tipo, int busco, int fin){ int medio, ini = 0, res = -1; fin--; for(int i = 0; i <= fin; ++i){ if(!visitado[i]){ if(tipo == 2){ S[i] = 1; }else{ S[i] = 0; } } } while(ini < fin){ medio = (ini + fin) / 2; for(int i = medio + 1; i <= fin; ++i){ if(!visitado[i]){ if(tipo == 1){ S[i] = 1; }else{ S[i] = 0; } } } if(tryCombination(S) != busco){ fin = medio; }else{ for(int i = medio + 1; i <= fin; ++i){ if(!visitado[i]){ if(tipo == 1){ S[i] = 0; }else{ S[i] = 1; } } } ini = medio + 1; } } visitado[ini] = true; if(tipo == 1){ S[ini] = 0; }else{ S[ini] = 1; } posiciones[ini] = busco; } void exploreCave(int N) { for(int i = 0; i < N; ++i){ int aux = prueba(i, N); bs(aux, i, N); } answer(S, posiciones); }

Compilation message (stderr)

cave.cpp: In function 'void bs(int, int, int)':
cave.cpp:22:25: warning: unused variable 'res' [-Wunused-variable]
   22 |     int medio, ini = 0, res = -1;
      |                         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...