Submission #1105672

#TimeUsernameProblemLanguageResultExecution timeMemory
1105672jadai007Cave (IOI13_cave)C++17
100 / 100
217 ms760 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N) { int swi[5005] = {0}, door[5005] = {0}, tmp[5005] = {0}, state[5005] = {0}; for(int i = 0; i < N; ++i){ int l = 0, r = N - 1; int ck = tryCombination(swi); int open = ((ck == -1 || ck > i) ? 1 : 0); while(l < r){ int mid = (l + r) >> 1; for(int j = 0; j < N; ++j) tmp[j] = swi[j]; for(int j = l; j <= mid; ++j) if(!state[j]) tmp[j]^=1; if(open){ if(tryCombination(tmp) == i) r = mid; else l = mid + 1; } else{ int ck = tryCombination(tmp); if(ck > i || ck == -1) r = mid; else l = mid + 1; } } door[r] = i; state[r] = 1; if(!open) swi[r]^=1; } answer(swi, door); }
#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...