Submission #632553

#TimeUsernameProblemLanguageResultExecution timeMemory
632553StavabCave (IOI13_cave)C++14
0 / 100
130 ms400 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; for(int i = 0; i < n; i++) { cur = tryCombination(S); if(cur > i || cur == -1) prev = 1; else prev = 0; int low = 0; int high = n - 1; while(high - low > 1) { int middle = (low + high) / 2; for(int j = low; j <= middle; j++) { if(D[j] == -1) { if(S[j] == 0) S[j] = 1; else S[j] = 0; } } int cur = tryCombination(S); if(cur > i || cur == -1) cur = 1; else cur = 0; if(cur == prev) low = middle; else high = middle; prev = cur; } if(D[low] == -1) { if(S[low] == 0) S[low] = 1; else S[low] = 0; cur = tryCombination(S); if(cur == prev) { D[high] = i; if(cur == i) { if(S[high] == 0) S[high] = 1; else S[high] = 0; } } else { D[low] = i; if(cur == i) { if(S[low] == 0) S[low] = 1; else S[low] = 0; } } } else { D[high] = i; cur = tryCombination(S); if(cur == i) { if(S[high] == 0) S[high] = 1; else S[high] = 0; } } } 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...