Submission #247063

#TimeUsernameProblemLanguageResultExecution timeMemory
247063arborCave (IOI13_cave)C++14
100 / 100
454 ms632 KiB
#include "cave.h" #include <bits/stdc++.h> bool done[5005]; int get(int S[]) { int ret = tryCombination(S); if (ret == -1) ret = 5001; return ret; } void exploreCave(int N) { int s[N], d[N]; memset(s, 0, sizeof(s)); for (int i = 0; i < N; i++) { int l = 0, r = N - 1; // assume doors [0, i-1] are already open for (int j = 0; j < N; j++) if (!done[j]) s[j] = 0; bool state = get(s) == i; for (int j = 0; j < N; j++) if (!done[j]) s[j] = !state; while (l < r) { int m = (l + r) / 2; for (int j = l; j <= m; j++) if (!done[j]) s[j] = state; int idx = get(s); for (int j = l; j <= m; j++) if (!done[j]) s[j] = !state; if (idx == i) l = m + 1; else r = m; } s[l] = state; d[l] = i; done[l] = true; } 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...