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(24, vector<ll> (n+1, 0));
for(ll i=0; i<24; i++){
if(i%4==0 || i%4==1) v[i][0]=0;
else v[i][0]=1;
}
for(ll i=1; i<=n; i++){
if(i%4==3) v[1][i]=-2;
else if(i%4==0) v[1][i]=-1;
else if(i%4==1) v[1][i]=-1;
else v[1][i]=-2;
}
for(ll i=2; i<4; i++){
for(ll j=1; j<=n; j++){
ll k=i/2+1, b=i%2, bj;
if((j & (1<<k))>0) bj=1;
else bj=0;
if(b==bj){
if(j%4==0) v[i][j]=-1;
else if(j%4==3) v[i][j]=-2;
else v[i][j]=1;
}
else if(bj==1){
if(k%2==0) v[i][j]=-1;
else v[i][j]=-2;
}
else{
if(k%2==0) v[i][j]=-2;
else v[i][j]=-1;
}
}
}
for(ll i=4; i<24; i++){
for(ll j=1; j<=n; j++){
ll k=i/2+1, b=i%2, bj;
if((j & (1<<k))>0) bj=1;
else bj=0;
if(b==bj){
ll bj1=0;
if((j & (1<<(k-1)))>0) bj1=1;
v[i][j]=2*k-4+bj1;
}
else if(bj==1){
if(k%2==0) v[i][j]=-1;
else v[i][j]=-2;
}
else{
if(k%2==0) v[i][j]=-2;
else v[i][j]=-1;
}
}
}
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... |