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 "prison.h"
#include <bits/stdc++.h>
using namespace std;
const int MAGIC = 7;
const int base[] = {2, 3, 3, 3, 3, 3, 3};
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(21, vector<int>(n + 1));
function<void(int, int, int, int)> Solve = [&](int x, int b, int L, int R) {
ans[x][0] = (b % 2 == 0 ? 0 : 1);
if (L >= R) {
return;
}
ans[x][L] = (b % 2 == 0 ? -1 : -2);
ans[x][R] = (b % 2 == 0 ? -2 : -1);
++L; --R;
if (L > R) {
return;
}
int len = R - L + 1;
int cur = L;
vector<int> v(1, L);
for (int i = 0; i + 1 < base[b]; i++) {
cur += (len + base[b] - 1) / base[b];
v.push_back(cur);
}
v.push_back(R + 1);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for (int i = 0; i + 1 < (int) v.size(); i++) {
int from = v[i];
int to = v[i + 1] - 1;
for (int v = L - 1; v < from; v++) {
ans[3 * (MAGIC - b - 1) + i + 1][v] = (b % 2 == 0 ? -2 : -1);
}
for (int v = from; v <= to; v++) {
ans[x][v] = 3 * (MAGIC - b - 1) + i + 1;
}
Solve(3 * (MAGIC - b - 1) + i + 1, b - 1, from, to);
for (int v = to + 1; v <= R + 1; v++) {
ans[3 * (MAGIC - b - 1) + i + 1][v] = (b % 2 == 0 ? -1 : -2);
}
}
};
Solve(0, MAGIC - 1, 1, n);
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... |