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;
vector<vector<int>> devise_strategy(int N){
if (N == 2) return {{0, 1, 2}, {1, 0, -1}, {1, -2, 0}};
int y = floor(log2(N))+1;
vector<vector<int>> a(3*y, vector<int>(N+1));
for (int i=0; i<3*y; i++){
for (int j=0; j<N+1; j++){
if (i % 3 == 0){
if (j == 0){
a[i][j] = 0;
continue;
}
a[i][j] = i+1+min(1, (j&(1<<(y-1-i/3))));
}
else {
if (j == 0){
a[i][j] = 1;
continue;
}
int b = 1+min(1, j&(1<<(y-1-i/3)));
if (b == i % 3) a[i][j] = (i+(3-i%3))%(3*y);
else {
if (b > i % 3) a[i][j] = -1;
else a[i][j] = -2;
}
}
}
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |