Submission #598889

#TimeUsernameProblemLanguageResultExecution timeMemory
598889pakhomoveeCave (IOI13_cave)C++17
100 / 100
790 ms460 KiB
#include "cave.h" #include <algorithm> using namespace std; void exploreCave(int N) { int right[N]; fill(right, right + N, 0); int match[N]; for (int i = 0; i < N; ++i) { int S[N]; int l = -1, r = N - 1; fill(S, S + N, 0); for (int j = 0; j < i; ++j) { S[match[j]] = right[match[j]]; } int my = 0; if (tryCombination(S) == i) { my = 1; } while (l + 1 < r) { int m = (l + r) / 2; fill(S, S + N, my ^ 1); for (int j = 0; j <= m; ++j) { S[j] ^= 1; } for (int j = 0; j < i; ++j) { S[match[j]] = right[match[j]]; } if (tryCombination(S) == i) { l = m; } else { r = m; } } match[i] = r; right[r] = my; } int revmatch[N]; for (int i = 0; i < N; ++i) { revmatch[match[i]] = i; } answer(right, revmatch); }
#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...