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;
void gen(int ord, int num, int l, int r, vector<vector<int>> &strat, const vector<int>& a) {
if (ord == (int) a.size()) {
assert(l + 1 == r);
strat[num][0] = ord % 2;
strat[num][l] = (ord % 2 == 0? -1 : -2);
strat[num][r] = (ord % 2 == 0? -2 : -1);
return;
}
int offset = 1;
for (int i = 0; i < ord; ++i) {
offset += a[i];
}
strat[num][0] = ord % 2;
strat[num][l] = (ord % 2 == 0? -1 : -2);
strat[num][r] = (ord % 2 == 0? -2 : -1);
for (int i = 0; i < a[ord]; ++i) {
strat[offset + i][l] = (ord % 2 == 0? -2 : -1);
strat[offset + i][r] = (ord % 2 == 0? -1 : -2);
}
++l, --r;
int len = (r - l + 1) / a[ord];
for (int i = 0; i < a[ord]; ++i) {
for (int x = l + len * i; x <= l + len * (i + 1) - 1; ++x) {
strat[num][x] = offset + i;
}
for (int j = 0; j < a[ord]; ++j) {
if (i == j) {
gen(ord + 1, offset + i, l + len * i, l + len * (i + 1) - 1, strat, a);
} else if (j < i) {
for (int x = l + len * j; x <= l + len * (j + 1) - 1; ++x) {
strat[offset + i][x] = (ord % 2 == 0? -2 : -1);
}
} else {
for (int x = l + len * j; x <= l + len * (j + 1) - 1; ++x) {
strat[offset + i][x] = (ord % 2 == 0? -1 : -2);
}
}
}
}
}
vector<vector<int>> genStrat(vector<int> a) {
int x = accumulate(a.begin(), a.end(), 0);
int n = 2;
for (int i = a.size() - 1; i >= 0; --i) {
n = n * a[i] + 2;
}
vector<vector<int>> strat(x + 1, vector<int>(n + 1, 0));
gen(0, 0, 1, n, strat, a);
return strat;
}
vector<vector<int>> devise_strategy(int N) {
vector<vector<int>> res = genStrat({3, 3, 3, 3, 2, 2, 2, 2});
for (auto &v : res) {
v.resize(N + 1);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |