이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
int max_dig = 12;
int x = 38;
bool at_b(int num){
return num % 3 == 0 ? 0 : 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] = at_b(i);
continue;
}
if(i == 0){
bool on = j & (1<<max_dig);
ret[i][j] = on ? 2 : 1;
continue;
}
if(!at_b(i)){
//A
int d = i / 3;
int pos = max_dig - d;
bool cur_on = j & (1<<pos);
ret[i][j] = 3 * d + (cur_on ? 2 : 1);
}
else if(at_b(i)){
//B
bool prev_on = i % 3 == 1 ? 0 : 1;
int d = i / 3;
int pos = max_dig - d;
bool cur_on = j & (1<<pos);
if(prev_on != cur_on){
ret[i][j] = prev_on ? -2 : -1;
}
else{
ret[i][j] = 3 * (d + 1);
}
}
else{
cout << "something wrong\n";
}
ret[i][j] = min(x, ret[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... |