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 "prison.h"
#include <vector>
using namespace std;
int digit(int num, int place,int base){
for(int i=0;i<place;i++){
num = num/base;
}
return num%base;
}
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vector<int> > ans;
vector<int> v;
v.push_back(0);
for(int i=1;i<=N;i++){
int s = 3;
int f = digit(i,s,3);
v.push_back(s + f*8 + 1);
}
ans.push_back(v);
for(int f=0;f<3;f++){
for(int s=0;s<8;s++){
vector<int> v;
int encoded = s + f*8 + 1;
//If given number is of A, check B, vice verca
if(s%2 == 1){
v.push_back(1);
}
else{
v.push_back(0);
}
// for(int i=0;;)
for(int i=1;i<=N;i++){
int rf,rs;
if(s>0)
rs = s - 1;
else{
rs = 0;
}
rf = digit(i,rs,3);
int d,e;
if(v[0] == 1){
d = -2;
e = -1;
}
else {
d = -1;
e = -2;
}
if(rf > f){
v.push_back(d);
}
else if(rf < f){
v.push_back(e);
}
else{
int encoded2 = rs + rf*8 + 1;
v.push_back(encoded2);
}
}
ans.push_back(v);
}
}
// for(auto v:ans){
// for(auto j:v){
// printf("%d ",j);
// }
// printf("\n");
// }
return ans;
}
Compilation message (stderr)
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:33:9: warning: unused variable 'encoded' [-Wunused-variable]
33 | int encoded = s + f*8 + 1;
| ^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |