Submission #1042153

#TimeUsernameProblemLanguageResultExecution timeMemory
1042153blackslexCave (IOI13_cave)C++17
100 / 100
346 ms604 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N) { int D[N] = {}, val[N] = {}, pos[N] = {}, revpos[N] = {}; for (int i = 0; i < N; i++) D[i] = val[i] = 0; for (int i = 0; i < N; i++) { auto apply = [&] (int idx, int st) { for (int j = 0; j <= idx; j++) D[j] = st; for (int j = idx + 1; j < N; j++) D[j] = !st; for (int j = 0; j < i; j++) D[pos[j]] = val[pos[j]]; }; auto get = [&] (int x) { int l = 0, r = N - 1; while (l < r) { int mid = (l + r) >> 1; apply(mid, x); int cval = tryCombination(D); if (cval > i || !(~cval)) r = mid; else l = mid + 1; } pos[i] = l; revpos[l] = i; val[l] = x; }; int ct = tryCombination(val); get(!(ct > i || !(~ct))); } answer(val, revpos); }
#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...