Submission #836896

#TimeUsernameProblemLanguageResultExecution timeMemory
836896JohannPrisoner Challenge (IOI22_prison)C++17
60 / 100
10 ms1152 KiB
#include "prison.h" #include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() std::vector<std::vector<int>> devise_strategy(int N) { int d = 1; while (1 << (d + 1) <= N) ++d; vvi ans(2 * d + 2, vi(N + 1)); vi bagSmaller = {-1, -2}; int bag = 0; ans[0][0] = bag; for (int i = 1; i <= N; ++i) ans[0][i] = ((1 << d) & i) ? 2 * d + 1 : 2 * d; for (int j = d; j > 0; --j) { bag ^= 1; ans[2 * j][0] = ans[2 * j + 1][0] = bag; for (int i = 1; i <= N; ++i) if (i & (1 << j)) { if (j > 1) ans[2 * j + 1][i] = 2 * (j - 1) + ((i >> (j - 1)) & 1); else ans[2 * j + 1][i] = bagSmaller[bag ^ (i & 1)]; ans[2 * j][i] = bagSmaller[bag ^ 1]; } else { ans[2 * j + 1][i] = bagSmaller[bag]; if (j > 1) ans[2 * j][i] = 2 * (j - 1) + ((i >> (j - 1)) & 1); else ans[2 * j][i] = bagSmaller[bag ^ (i & 1)]; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...