Submission #107216

#TimeUsernameProblemLanguageResultExecution timeMemory
107216nickyrioCave (IOI13_cave)C++17
100 / 100
458 ms504 KiB
#include "cave.h" #include <cstdio> void exploreCave(int N) { int S[N], D[N]; for (int i = 0; i < N; ++i) S[i] = 0, D[i] = -1; for (int i = 0; i < N; ++i) { int l = 0, r = N - 1, pos = N; int res = tryCombination(S); if (res == -1) res = N + 1; if (res > i) { for (int j = 0; j < N; ++j) if (D[j] == -1) S[j] ^= 1; } while (l <= r) { // printf("L = %d, R = %d", l, r); int m = (l + r) >> 1; for (int j = l; j <= m; ++j) if (D[j] == -1) S[j] ^= 1; res = tryCombination(S); if (res == -1) res = N + 1; // printf("Res = %d\n", res); if (res > i) { // Door i is open pos = m; r = m; if (l == r) break; } else l = m + 1; for (int j = l; j <= m; ++j) if (D[j] == -1) S[j] ^= 1; } D[pos] = i; //printf("Switch %d is connected with door %d\n", pos, i); } 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...