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;
std::vector<std::vector<int>> devise_strategy(int n) {
int x = 26;
vector ans(x + 1, vector(n + 1, 0));
for (int i = 0; i <= x; i++) {
if (i == 0) {
ans[i][0] = 0;
for (int j = 1; j <= n; j++) {
ans[i][j] = 1 + ((j & (1 << 12)) > 0 ? 1 : 0);
}
} else if ((i - 1) % 4 <= 1) {
ans[i][0] = 1;
int a = (i - 1) % 4, k = 12 - (i - 1) / 2;
for (int j = 1; j <= n; j++) {
int b = (j & (1 << k)) > 0;
if (a == b) {
b = (j & (1 << (k - 1))) > 0;
ans[i][j] = i - a + 2 + b;
if (ans[i][j] > x) ans[i][j] = 0;
continue;
}
ans[i][j] = (a > b ? -2 : -1);
}
} else {
ans[i][0] = 0;
int b = (i - 3) % 4, k = 12 - (i - 1) / 2;
for (int j = 1; j <= n; j++) {
int a = (j & (1 << k)) > 0;
if (a == b) {
a = (j & (1 << (k - 1))) > 0;
ans[i][j] = i - b + 2 + a;
continue;
}
ans[i][j] = (a > b ? -2 : -1);
}
}
}
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... |