제출 #648675

#제출 시각아이디문제언어결과실행 시간메모리
648675a_aguilo동굴 (IOI13_cave)C++14
100 / 100
822 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; memset(ns,1-abrir,sizeof(ns)); for(int i=lo; i<=mid; i++){ if(d[i] != -1){ ns[i] = s[i]; }else ns[i] = abrir; } for(int i = 0; i < N; ++i){ if(d[i] != -1){ ns[i] = s[i]; } } /* for(int i=mid; i<hi; i++){ if(d[i] != -1){ ns[i] = s[i]; }else ns[i] = (1-abrir); } */ int temp = tryCombination(ns); if(temp == puerta){ lo = mid+1; }else{ hi = 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 abrir = 0; if(temp == i) //Se abre i con 1 abrir = 1; int sol = interruptor(i,abrir,N,s,d); s[sol] = abrir; //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...