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;
#define ll long long
string bit3(int n){
n--;
string s="";
for(int i=0;i<8;i++){
s=char((n%3)+48)+s;
n/=3;
}
return s;
}
vector<vector<int>> devise_strategy(int n){
vector<vector<int>>s(23,vector<int>(n+1,0));
int cur=2187;
int add=1;
for(int i=1;i<=n;i++){
int x=i-1;
s[0][i]=x/cur+add;
}
string b[n+5];
for(int i=1;i<=n;i++){
b[i]=bit3(i);
}
for(int i=0;i<=6;i++){
add+=3;
for(int j=i*3+1;j<=i*3+3;j++){
s[j][0]=1-i%2;
for(int k=1;k<=n;k++){
int bit=b[k][i]-48;
int befBit=j-i*3-1;
if(bit<befBit){
s[j][k]=-(s[j][0]==0?1:2);
}
else if(bit>befBit){
s[j][k]=-(s[j][0]==0?2:1);
}
else{
if(add+bit<=21){
s[j][k]=add+b[k][i+1]-48;
}
else if(add+bit<=24){
if(b[k][i+1]=='0'){
s[j][k]=-2;
}
else if(b[k][i+1]=='2'){
s[j][k]=-1;
}
else{
s[j][k]=22;
}
}
else{
s[j][k]=-1;
}
}
}
}
cur/=3;
}
s[22][0]=0;
for(ll i=1;i<=n;i++){
if(b[i][7]=='0'){
s[22][i]=-1;
}
else{
s[22][i]=-2;
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |