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;
int k = 3, p[9];
std::vector<std::vector<int>> devise_strategy(int n){
p[0] = 1;
for(int i = 1; i <= 8; ++i) p[i] = p[i - 1] * 3;
vector<vector<int>> v(25);
for(int i = 0; i <= 24; ++i) v[i].resize(n+1);
v[0][0] = 0;
for(int i = 1; i <= 24; ++i) v[i][0] = (((i-1)/3)%2 ? 0 : 1);
for(int i = 1; i <= n; ++i){
v[0][i] = (i / p[8]);
}
for(int i = 1; i <= 24; ++i){
for(int j = 1; j <= n; ++j){
int x = (i - 1) / 3;
int val = (i - 1) % 3;
int d = j;
for(int l = 0; l < x; ++l) d /= 3;
int divisor = p[8 - x];
if(x % 3){
if(d / divisor != val){
v[i][j] = (d / divisor < val ? -2 : -1);
}else{
v[i][j] = d / divisor + (x * 3 + 1);
}
}else{
if(d / divisor != val){
v[i][j] = (d / divisor < val ? -1 : -2);
}else{
v[i][j] = d / divisor + (x * 3 + 1);
}
}
}
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |