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>
using namespace std;
typedef long long ll;
ll x=24;
ll bsbit=8;
ll r[2]={-1,-2};//Respuesta
vector<int> bs={2187,729,243,81,27,9,3,1};
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vector<int>> v (x+1,vector<int> (N + 1, 0));
for(int i=0;i<=x;i++){
if(i==0){
v[0][0]=1;
for(int j=1;j<=N;j++){
ll valuebit=(j/bs[0])%3;
v[i][j]=1+(valuebit*bsbit+0);
//cerr<<v[i][j]<<" ";
}//cerr<<"\n\n";
continue;
}//cout
ll inf=i-1;
ll bit=inf%bsbit;
ll value=inf/bsbit;
v[i][0]=bit%2;
for(int j=1;j<=N;j++){
ll valuebit=(j/bs[bit])%3;
ll valuenext=0;
if(bit+1<bs.size())valuenext=(j/bs[bit+1])%3;
if(value==valuebit){
v[i][j]=1+(valuenext*bsbit+bit+1);
}
else{
if(valuebit<value)v[i][j]=r[v[i][0]];
else v[i][j]=r[v[i][0]^1];
}
//cerr<<v[i][j]<<" ";
}//cerr<<"\n\n";
}
return v;
}
Compilation message (stderr)
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:27:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | if(bit+1<bs.size())valuenext=(j/bs[bit+1])%3;
| ~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |