#include "prison.h"
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
vector<vector<int>> devise_strategy(int n) {
int b = 1;
while ((1 << b) <= n) b++;
int x = 3 * b - 1;
vector<vector<int>> ans(x + 1, vector<int>(n + 1, 0));
for (int st = 0; st <= x; st++) {
int s = st / 3;
int t = st % 3;
ans[st][0] = (t != 0);
for (int v = 1; v <= n; v++) {
int bit = (v >> (b - s - 1)) & 1;
if (t == 0) {
ans[st][v] = (st + 1) + bit;
} else {
int ab = t - 1;
int bb = bit;
if (ab < bb) ans[st][v] = -1;
else if (ab > bb) ans[st][v] = -2;
else {
ans[st][v] = (s != b - 1) ? (3 * (s + 1)) : 0;
}
}
}
}
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... |