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) {
int s=0;
while((1<<s)<=N)s++;
int x=3*s-1;
vector<vector<int>> ans(x+1,vector<int>(N+1,0));
for(int i=0;i<=x;i++)ans[i][0]=((i%3)!=0);
for(int i=0;i<x-1;i++){
for(int j=1;j<N+1;j++){
int p = i/3;
int b = s-p-1;
if(i%3==0){
if(j&(1<<b))ans[i][j]=i+1;
else ans[i][j]=i+2;
}else if(i%3==1){
if(j&(1<<b))ans[i][j]=i+2;
else ans[i][j]=-2;
}else{
if(j&(1<<b))ans[i][j]=-1;
else ans[i][j]=i+1;
}
}
}
for(int j=1;j<N+1;j++){
if(j&1)ans[x-1][j]=0;
else ans[x-1][j]=-2;
if(j&1)ans[x][j]=-1;
else ans[x][j]=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... |