This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
std::vector <std::vector <int>> devise_strategy(int n) {
std::vector <std::vector <int>> ans(22, std::vector <int> (n + 1));
auto f = [&] (auto&& self, int l, int r, int pl, int pr, int it, int bx, int pbx) -> void {
if (l > r) {
return;
}
int bag = it & 1;
ans[it * 3 + bx][0] = bag;
int bou1 = (l * 2 + r + 1) / 3;
int bou2 = (r * 2 + l - 1) / 3;
for (int i = pl; i <= pr; i++) {
if (i >= l && i <= r) {
ans[pbx][i] = it * 3 + bx;
}
if (i <= l || i >= r) {
ans[it * 3 + bx][i] = i <= l ? ~bag : ~(1 ^ bag);
}
}
if (l + 1 > r - 1) {
return;
}
self(self, l + 1, bou1, l, r, it + 1, 1, it * 3 + bx);
self(self, bou1 + 1, bou2, l, r, it + 1, 2, it * 3 + bx);
self(self, bou2 + 1, r - 1, l, r, it + 1, 3, it * 3 + bx);
};
f(f, 1, n, 1, n, -1, 3, 0);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |