#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
#define vec vector
bool on(int x, int i) {
assert(i >= 0);
return x & (1 << i);
}
vec<vec<int>> devise_strategy(int n) {
int k = 26;
vec<vec<int>> ans(k + 1, vec<int>(n + 1, 0));
for (int i = 0; i <= k; i++) {
int b = 13 - (i + 1) / 2;
if (i % 4 == 0 || i % 4 == 3) {
ans[i][0] = 0;
for (int j = 1; j <= n; j++) {
int x = on(j, b);
int y = (i % 2 == 0);
if (i != 0 && x && !y) {
ans[i][j] = -2;
} else if (i != 0 && y && !x) {
ans[i][j] = -1;
} else if (b == 0) {
ans[i][j] = 0;
} else {
int z = on(j, b - 1);
ans[i][j] = i + ((i % 2 == 0) ? 0 : 1) + 1 + z;
}
}
} else {
ans[i][0] = 1;
for (int j = 1; j <= n; j++) {
int x = on(j, b);
int y = (i % 2 == 0);
if (i != 0 && x && !y) {
ans[i][j] = -1;
} else if (i != 0 && y && !x) {
ans[i][j] = -2;
} else if (b == 0) {
ans[i][j] = 0;
} else {
int z = on(j, b - 1);
ans[i][j] = i + ((i % 2 == 0) ? 0 : 1) + 1 + z;
}
}
}
}
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... |