이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int solve(int a){
return to_string(a).size();
}
int find_digit(int a, int i){
return (to_string(a)[i] - 48);
}
vector<vector<int>> devise_strategy(int n){
int x = 100;
vector<vector<int>> out(x, vector<int>(n + 1, 0));
for (int i = 1; i <= n; ++i){
out[0][i] = solve(i);
}
for (int i = 1; i <= 4; ++i){
out[i][0] = 1;
for (int j = 1; j <= n; ++j){
if (solve(j) > i){
out[i][j] = -1;
continue;
}
if (solve(j) < i){
out[i][j] = -2;
continue;
}
out[i][j] = 10 + find_digit(j, 0);
}
}
for (int i = 10; i <= 19; ++i){
out[i][0] = 0;
for (int j = 1; j <= n; ++j){
int k = find_digit(j, 0);
if (k > i - 10){
out[i][j] = -2;
continue;
}
if (k < i - 10){
out[i][j] = -1;
continue;
}
out[i][j] = 20 + find_digit(j, 1);
}
}
for (int i = 20; i <= 29; ++i){
out[i][0] = 1;
for (int j = 1; j <= n; ++j){
int k = find_digit(j, 1);
if (k > i - 20){
out[i][j] = -1;
continue;
}
if (k < i - 20){
out[i][j] = -2;
continue;
}
out[i][j] = 30 + find_digit(j, 2);
}
}
for (int i = 30; i <= 39; ++i){
out[i][0] = 0;
for (int j = 1; j <= n; ++j){
int k = find_digit(j, 2);
if (k > i - 30){
out[i][j] = -2;
continue;
}
if (k < i - 30){
out[i][j] = -1;
continue;
}
out[i][j] = 40 + find_digit(j, 3);
}
}
for (int i = 40; i <= 49; ++i){
out[i][0] = 1;
for (int j = 1; j <= n; ++j){
int k = find_digit(j, 3);
if (k > i - 40){
out[i][j] = -1;
continue;
}
if (k < i - 40){
out[i][j] = -2;
}
}
}
for (int i = 0; i < x; ++i){
for (int j = 0; j < n + 1; ++j){
if (out[i][j] < -2){
out[i][j] = 0;
}
}
}
return out;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |