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>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
int B[] = {3, 3, 3, 3, 3, 3, 2};
int P[] = {1, 4, 7, 10, 13, 16, 19, 21};
int S[] = {5102, 1700, 566, 188, 62, 20, 6, 2};
vvi f;
int slv(int b, int i, int l, int r) {
f[i][l] = (b & 1) ? -1 : -2;
f[i][r] = (b & 1) ? -2 : -1;
if (b == 7)
return i;
for (int j = 0; j < B[b]; j++) {
int l_ = l + 1 + j * S[b + 1];
int r_ = l + (j + 1) * S[b + 1];
int i_ = P[b] + j;
slv(b + 1, i_, l_, r_);
for (int v = l_; v <= r_; v++)
f[i][v] = i_;
for (int v = l; v <= l_ - 1; v++)
f[i_][v] = (b & 1) ? -2 : -1;
for (int v = r_ + 1; v <= r; v++)
f[i_][v] = (b & 1) ? -1 : -2;
}
return i;
}
vvi devise_strategy(int n) {
f.assign(21, vi(5103, 1));
slv(0, 0, 1, 5102);
f[0][0] = 1;
for (int b = 0, p = 1; b < 7; b++)
for (int i = 0; i < B[b]; i++)
f[p++][0] = b & 1;
for (vi& v : f)
v.resize(n + 1);
return f;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |