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;
vector<vector<int>> devise_strategy(int n){
int d[10] = {3, 3, 3, 3, 3, 2, 2, 1, 1, 1};
int p[21], pp[21], pref[8] = {0, 3, 6, 9, 12, 15, 17, 19};
p[0] = pp[0] = 0;
for(int i = 0, cur = 0; i <= 20; cur++){
for(int j = i + 1; j <= i + d[cur]; ++j){
p[j] = cur + 1;
pp[j] = j - i - 1;
}
i += d[cur];
}
int b = 8;
vector<string> dp;
function<void(int, string)> generate = [&](int depth, string str){
dp.push_back(str + string(b - depth + 1, 'L'));
if(depth < b){
for(char i = '0'; i < d[depth] + '0'; ++i){
generate(depth + 1, str + i);
}
}
dp.push_back(str + string(b - depth + 1, 'R'));
};
generate(0, "");
vector<vector<int>> v(21);
for(int i = 0; i <= 20; ++i) v[i].resize(n + 1);
for(int i = 0; i <= 20; ++i){
int s = p[i], t = pp[i];
v[i][0] = (s % 2); // s is even: A, s is odd: B
for(int j = 1; j <= n; ++j){
if(s == 0){
if(dp[j][s] == 'L'){
v[i][j] = -1;
}else if(dp[j][s] == 'R'){
v[i][j] = -2;
}else{
v[i][j] = pref[s] + 1 + (dp[j][s] - '0');
}
}else if(s % 2){
int abit = t;
int bbit = dp[j][s - 1] - '0';
if(dp[j][s - 1] == 'R'){
v[i][j] = -1;
}else if(dp[j][s - 1] == 'L'){
v[i][j] = -2;
}else if(abit < bbit){
v[i][j] = -1;
}else if(bbit < abit){
v[i][j] = -2;
}else if(dp[j][s] == 'L'){
v[i][j] = -2;
}else if(dp[j][s] == 'R'){
v[i][j] = -1;
}else{
v[i][j] = pref[s] + 1 + (dp[j][s] - '0');
}
}else{
int abit = dp[j][s - 1] - '0';
int bbit = t;
if(dp[j][s - 1] == 'L'){
v[i][j] = -1;
}else if(dp[j][s - 1] == 'R'){
v[i][j] = -2;
}else if(abit < bbit){
v[i][j] = -1;
}else if(bbit < abit){
v[i][j] = -2;
}else if(dp[j][s] == 'L'){
v[i][j] = -1;
}else if(dp[j][s] == 'R'){
v[i][j] = -2;
}else{
v[i][j] = pref[s] + 1 + (dp[j][s] - '0');
}
}
}
}
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... |