제출 #101964

#제출 시각아이디문제언어결과실행 시간메모리
101964Plurm동굴 (IOI13_cave)C++11
100 / 100
1342 ms596 KiB
#include "cave.h" #include <cstdio> #include <cstring> void exploreCave(int N) { int forced[N]; memset(forced,-1,sizeof(forced)); int conn[N]; int now[N]; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(forced[j] != -1) now[j] = forced[j]; else now[j] = 0; } int res = tryCombination(now); if(res > i || res == -1){ int lo = 0; int hi = N-1; int mid; while(lo < hi){ mid = (lo + hi)/2; for(int j = 0; j <= mid; j++){ now[j] = 1; if(forced[j] != -1) now[j] = forced[j]; } for(int j = mid+1; j <= N; j++){ now[j] = 0; if(forced[j] != -1) now[j] = forced[j]; } res = tryCombination(now); if(res == i){ hi = mid; }else{ lo = mid+1; } } forced[lo] = 0; conn[lo] = i; }else{ int lo = 0; int hi = N-1; int mid; while(lo < hi){ mid = (lo + hi)/2; for(int j = 0; j <= mid; j++){ now[j] = 1; if(forced[j] != -1) now[j] = forced[j]; } for(int j = mid+1; j <= N; j++){ now[j] = 0; if(forced[j] != -1) now[j] = forced[j]; } res = tryCombination(now); if(res > i || res == -1){ hi = mid; }else{ lo = mid+1; } } forced[lo] = 1; conn[lo] = i; } } answer(forced, conn); }
#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...