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 pb push_back
#define mp make_pair
int conv(int id){
if (id==0) return -1;
return -2;
}
int numbitt(int x){
int res=0;
while (x>0){
x/=3;
res++;
}
return res;
}
int bitt(int x,int bit){
while (bit--) x/=3;
return x%3;
}
vector<vector<int> > devise_strategy(int n){
int numbit=numbitt(n);
vector<vector<int> > ans(numbit*3-1,vector<int>(n+1,0));
ans[0][0]=0;
for (int j=1;j<=n;j++){
ans[0][j]=bitt(j,numbit-1)+1;
}
for (int i=1;i<(int)ans.size();i++){
int lol=(i+2)/3;
if (lol%2==0) ans[i][0]=0;
else ans[i][0]=1;
int bit=numbit-lol;
for (int j=1;j<=n;j++){
if (bit==0){
if (bitt(j,bit)==0) ans[i][j]=conv(ans[i][0]);
else if (bitt(j,bit)==2) ans[i][j]=conv(1-ans[i][0]);
else ans[i][j]=0;
continue;
}
if ((i-1)%3<bitt(j,bit) || j==n){
ans[i][j]=conv(1-ans[i][0]);
}
else if ((i-1)%3>bitt(j,bit) || j==1){
ans[i][j]=conv(ans[i][0]);
}
else {
if (bit>1) ans[i][j]=lol*3+1+bitt(j,bit-1);
else ans[i][j]=lol*3+1;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |