Submission #648499

#TimeUsernameProblemLanguageResultExecution timeMemory
648499ojoConmigoCave (IOI13_cave)C++17
0 / 100
409 ms460 KiB
#include "cave.h" #include <bits/stdc++.h> int interruptor(int puerta, int abrir, int N,int s[], int d[]){ int ns[N]; int lo = 0, hi = N-1,res = -1; while(lo <= hi){ int mid = lo + (hi-lo)/2; for(int i=0; i<mid; i++){ if(d[i] != -1){ ns[i] = s[i]; }else ns[i] = abrir; } for(int i=mid; i<N; i++){ if(d[i] != -1){ ns[i] = s[i]; }else ns[i] = (1-abrir); } int temp = tryCombination(ns); if(temp == puerta){ hi = mid-1; }else{ lo = mid+1; res = mid; } } return res; } void exploreCave(int N) { int s[N],d[N]; //bool encontrado[N]; //swichts memset(s,0,sizeof(s)); memset(d,-1,sizeof(d)); for(int i=0; i<N; i++){ int temp = tryCombination(s); int sol = -1; if(temp == i){ //Se abre i con 1 sol = interruptor(i,1,N,s,d); s[sol] = 1; }else{//Se abre i con 0 sol = interruptor(i,0,N,s,d); s[sol] = 0; } //el interruptor de la puerta i es sol d[sol] = i; //encontrado[sol] = true; } answer(s,d); }
#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...