# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
637486 | Fidan | Prisoner Challenge (IOI22_prison) | C++17 | 0 ms | 0 KiB |
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>=4096) v[0][i]=23;
else v[0][i]=22;
}
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=2, 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;
}
//~ int main(){
//~ ll n;
//~ cin>>n;
//~ vector<vector<ll>> v=devise_strategy(n);
//~ for(ll i=0; i<24; i++){
//~ cout<<i<<" : ";
//~ for(ll j=0; j<=n; j++){
//~ cout<<v[i][j]<<" ";
//~ }
//~ cout<<endl;
//~ }
//~ return 0;
}