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;
ll pw[8]={1, 3, 9, 27, 81, 243, 729, 2187};
vector<vector<ll>> devise_strategy(ll n){
vector<vector<ll>> v(22, vector<ll> (n+1));
for(ll i=0; i<22; i++){
if(((i+2)/3)%2==0) v[i][0]=0;
else v[i][0]=1;
}
for(ll i=1; i<=n; i++){
v[0][i]=i/pw[7]+19;
}
for(ll i=7; i<22; i++){
for(ll j=1; j<=n; j++){
ll k=(i+2)/3, bit=(i+2)%3;
ll bj=(j/pw[k])%3;
if(bj==bit){
v[i][j]=(j/pw[k-1])%3+3*k-5;
}
else if(bj>bit){
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<7; i++){
for(ll j=1; j<=n; j++){
ll k=(i+2)/3, bit=(i+2)%3;
ll bj=(j/pw[k])%3;
if(bj==bit){
if(j%9==1) v[i][j]=-1;
else if(j%9==8) v[i][j]=-2;
else if(j%9<=3) v[i][j]=1;
else if(j%9<=5) v[i][j]=2;
else v[i][j]=3;
}
else if(bj>bit){
v[i][j]=-2;
}
else{
v[i][j]=-1;
}
}
}
for(ll i=1; i<4; i++){
for(ll j=1; j<=n; j++){
if(j%9<=2*i) v[i][j]=-1;
else v[i][j]=-2;
}
}
for(ll i=0; i<22; i++){
v[i][1]=-v[i][0]-1;
v[i][n]=v[i][0]-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... |