Submission #638295

#TimeUsernameProblemLanguageResultExecution timeMemory
638295FidanPrisoner Challenge (IOI22_prison)C++17
0 / 100
0 ms212 KiB
#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+1) v[i][j]=-1; else if(j%9<2*i) v[i][j]=-2; else if(j%9==2*i) v[i][j]=-2; else v[i][j]=-1; } } for(ll i=0; i<22; i++){ v[i][1]=-v[i][0]-1; v[i][n]=v[i][n]-2; } return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...