Submission #629376

#TimeUsernameProblemLanguageResultExecution timeMemory
629376StavabCave (IOI13_cave)C++14
0 / 100
20 ms368 KiB
#include "cave.h" void exploreCave(int n) { int s[n], d[n]; for(int i = 0; i < n; i++) { s[i] = 0; d[i] = -1; } int cur, prev, door; for(int i = 0; i < n; i++) { door = tryCombination(s); if(door > i || door == -1) prev = 1; else prev = 0; int low = 0, high = n; while(high - low > 1) { int middle = (low + high) / 2; for(int j = low; j <= middle; j++) { if(d[j] != -1) continue; if(s[j]) s[j] = 0; else s[j] = 1; } door = tryCombination(s); if(door > i || door == -1) cur = 1; else cur = 0; if(cur == prev) low = middle; else high = middle; prev = cur; } if(s[low]) s[low] = 0; else s[low] = 1; door = tryCombination(s); if(door > i || door == -1) cur = 1; else cur = 0; int ind; if(cur == prev) { d[high] = i; ind = high; } else { d[low] = i; ind = low; } door = tryCombination(s); if(door <= i) { if(s[ind]) s[ind] = 0; else s[ind] = 1; } } 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...