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;
#define sz(v) int(v.size())
const int B = 12;
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(2 * B + 1, vector<int>(n + 1));
for (int i = 0; i < sz(ans); i++) {
if (i == 0) {
ans[i][0] = 0;
int b = 0;
for (int j = 1; j <= n; j++) {
if ((j >> (B - b)) & 1) {
ans[i][j] = 2;
} else {
ans[i][j] = 1;
}
}
} else {
int b = (i - 1) / 2;
int last = (i - 1) % 2;
if (b % 2 == 0) {
ans[i][0] = 1;
} else {
ans[i][0] = 0;
}
for (int j = 1; j <= n; j++) {
int cur = (j >> (B - b)) & 1;
if (cur != last) {
if (cur < last) ans[i][j] = -ans[i][0] - 1;
else ans[i][j] = -(ans[i][0] ^ 1) - 1;
} else {
if ((j >> (B - b - 1)) & 1) {
if (b == B-1) {
ans[i][j] = -(ans[i][0] ^ 1) - 1;
} else {
ans[i][j] = 2 * (b + 1) + 2;
}
} else {
if (b == B-1) {
ans[i][j] = -ans[i][0] - 1;
} else {
ans[i][j] = 2 * (b + 1) + 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... |