제출 #864922

#제출 시각아이디문제언어결과실행 시간메모리
864922dpsaveslives동굴 (IOI13_cave)C++17
100 / 100
188 ms808 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5005; bool vis[MAXN]; //save for all switches if we set them already int S[MAXN], ans[MAXN]; void exploreCave(int N){ //memset for(int i = 0;i<N;++i){ if(tryCombination(S) == i){ for(int j = 0;j<N;++j){ if(!vis[j]) S[j] = 1-S[j]; } } int lo = 0, hi = N-1; while(lo < hi){ int mid = (lo+hi)/2; for(int j = lo;j<=mid;++j){ if(!vis[j]) S[j] = 1-S[j]; } if(tryCombination(S) == i) hi = mid; else lo = mid+1; for(int j = lo;j<=mid;++j){ if(!vis[j]) S[j] = 1-S[j]; } } vis[lo] = true; ans[lo] = i; } answer(S,ans); }
#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...