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(23, vector<ll> (n+1));
for(ll i=0; i<23; i++){
if(((i+1)/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]+20;
}
for(ll i=8; i<23; i++){
for(ll j=1; j<=n; j++){
ll k=(i+1)/3, bit=(i+1)%3;
ll bj=(j/pw[k])%3;
if(bj==bit){
v[i][j]=(j/pw[k-1])%3+3*k-4;
}
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=5; i<8; i++){
for(ll j=1; j<=n; j++){
ll k=(i+1)/3, bit=(i+1)%3;
ll bj=(j/pw[k])%3;
if(bj==bit){
if(j%9==0) v[i][j]=-1;
else if(j%9==8) v[i][j]=-2;
else if(j%9<=2) v[i][j]=1;
else if(j%9<=4) v[i][j]=2;
else if(j%9<=6) v[i][j]=3;
else v[i][j]=4;
}
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-1) v[i][j]=-2;
else if(j%9>=2*i) v[i][j]=-1;
}
}
for(ll i=0; i<23; i++){
v[i][1]=-v[i][0]-1;
v[i][n]=v[i][0]-2;
}
return v;
}
//~ int main(){
//~ ll n;
//~ cin>>n;
//~ vector<vector<ll>> r=devise_strategy(n);
//~ for(ll i=0; i<23; i++){
//~ cout<<i<<" : ";
//~ for(ll j=0; j<=n; j++){
//~ cout<<r[i][j]<<" ";
//~ }
//~ cout<<endl;
//~ }
//~ }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |