Submission #836904

#TimeUsernameProblemLanguageResultExecution timeMemory
836904JohannPrisoner Challenge (IOI22_prison)C++17
65 / 100
14 ms1116 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)]; } } for (int j = 2; j < sz(ans); ++j) swap(ans[j - 1], ans[j]); ans.pop_back(); for (int j = 0; j < sz(ans); ++j) for (int i = 1; i < sz(ans[j]); ++i) if (ans[j][i] > 0) --ans[j][i]; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...