이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
int f(int a, int b) {
while (b--) {
a /= 3;
}
return a % 3;
}
vector<vector<int>> devise_strategy(int N) {
vector a(23, vector<int>(N + 1));
for (int i = 10; i <= 21; i++) {
a[i][0] = 1;
}
for (int j = 1; j <= N; j++) {
for (int i = 0; i <= 9; i++) {
int t = (9 - i) / 3 * 2 + 1;
if (f(i, 0) != f(j, t + 1)) {
a[i][j] = -2 + (f(i, 0) > f(j, t + 1));
} else {
a[i][j] = 12 + (7 - t) / 2 * 3 - (3 - f(j, t)) % 3;
}
}
for (int i = 10; i <= 21; i++) {
int t = (21 - i) / 3 * 2;
if (f(i, 0) != f(j, t + 1)) {
a[i][j] = -1 - (f(i, 0) > f(j, t + 1));
} else {
a[i][j] = (8 - t) / 2 * 3 - (3 - f(j, t)) % 3;
if (t == 0) {
if (f(j, t) == 0) {
a[i][j] = -2;
} else if (f(j, t) == 2) {
a[i][j] = -1;
} else {
a[i][j] = 22;
}
}
}
}
a[22][j] = -2 + (f(j, 0) == 0);
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |