#include<bits/stdc++.h>
#include "prison.h"
using namespace std;
template<class T>void minimize(T& a, T b){
if(a > b){
a = b;
}
}
vector<vector<int>>devise_strategy(int n){
vector<vector<int>>s(27, vector<int>(n + 1));
s[0][0] = 0;
auto get = [&] (int bit, bool parity){
return ((12 - bit) << 1) + int(parity) + 1;
};
for(int i = 1; i <= n; i++){
s[0][i] = 1 + ((i >> 12) & 1);
}
for(int i = 1; i < 27; i++){
bool on = bool((i & 1) ^ 1);
int bit = 12 - ((i - 1) >> 1);
if(bit & 1){
s[i][0] = 0;
for(int j = 1; j <= n; j++){
if(1 << bit & j){
s[i][j] = (on ? ((bit == 0 ? 26 : get(bit - 1, (j >> (bit - 1)) & 1))) : -2);
}
else{
s[i][j] = (on ? -1 : ((bit == 0 ? 26 : get(bit - 1, (j >> (bit - 1)) & 1))));
}
}
}
else{
s[i][0] = 1;
for(int j = 1; j <= n; j++){
if(1 << bit & j){
s[i][j] = (on ? ((bit == 0 ? 26 : get(bit - 1, (j >> (bit - 1)) & 1))) : -1);
}
else{
s[i][j] = (on ? -2 : ((bit == 0 ? 26 : get(bit - 1, (j >> (bit - 1)) & 1))));
}
}
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |