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 <bits/stdc++.h>
#include "prison.h"
using namespace std;
typedef int ll;
vector<vector<ll>> devise_strategy(ll n){
vector<vector<ll>> v(25, vector<ll> (n+1));
v[0][0]=0;
ll i, j, k, bit, a, bj1, bj;
for(i=1; i<=n; i++){
if(i>=4096) v[0][i]=24;
else v[0][i]=23;
}
v[0][n]=-2;
for(i=1; i<25; i++){
if(i%4==0 || i%4==3) v[i][0]=1;
else v[i][0]=0;
}
for(j=1; j<=n; j++){
a=j/2%2;
if(a==1){
v[1][j]=-2;
if(j%2==0) v[2][j]=-1;
else v[2][j]=-2;
}
else{
v[2][j]=-1;
if(j%2==0) v[1][j]=-1;
else v[1][j]=-2;
}
}
for(i=3; i<25; i++){
for(j=1; j<=n; j++){
k=(i+1)/2;
bit=(i+1)%2;
if((j & (1<<k))>0) bj=1;
else bj=0;
if(bj==bit){
if((j & (1<<(k-1)))>0) bj1=1;
else bj1=0;
v[i][j]=2*k-3+bj1;
}
else if(bj==1){
if(v[0][j]==0) v[i][j]=-2;
else v[i][j]=-1;
}
else{
if(v[0][j]==0) v[i][j]=-1;
else v[i][j]=-2;
}
}
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |