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 <iostream>
#include <vector>
using namespace std;
int max_dig = 12;
int x = 38;
int compare(int i , int j){
bool prev_on = i % 3 == 1 ? 0 : 1;
int d = i / 3;
int prev_d = d - 1;
int prev_pos = max_dig - prev_d;
int cur_pos = max_dig - d;
bool cur_on = j & (1<<prev_pos);
int a = d % 2 == 0;
if(prev_on != cur_on){
return ((prev_on && a) || (!prev_on && !a)) ? -1 : -2;
}
if(cur_pos == 0){
return (((j & 1) && a) || (!(j & 1) && !a)) ? -2 : -1;
}
bool now_on = j & (1<<cur_pos);
return 3 * (d + 1) + (now_on ? 2 : 1);
}
vector<vector<int>> devise_strategy(int n){
vector<vector<int>> ret(x + 1, vector<int>(n+1));
for(int i = 0; i <= x; ++i){
for(int j = 0; j <= n; ++j){
if(j == 0){
ret[i][j] = (i/3)%2;
continue;
}
if(i == 0){
bool on = j & (1<<max_dig);
ret[i][j] = 3 + (on ? 2 : 1);
continue;
}
ret[i][j] = min(x, compare(i, j));
}
}
ret[0][0] = 0;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |