이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "grader.h"
char dp[501][501][501];
bool sel[501][501][501];
char dfs(const int l, const int r, const int x) {
if (l == r) return 0;
if (dp[l][r][x] != 0) return dp[l][r][x];
char min = 100;
if (l < x) {
const int i = l;
char max = 0;
if ((i + x) / 2 + 1 <= r) {
max = std::max(max, dfs(std::max(l, (i + x) / 2 + 1), r, i));
}
if (l <= (i + x - 1) / 2) {
max = std::max(max, dfs(l, std::min((i + x - 1) / 2, r), i));
}
if (min > max) {
min = max;
sel[l][r][x] = false;
}
}
if (x < r) {
const int i = r;
char max = 0;
if ((i + x) / 2 + 1 <= r) {
max = std::max(max, dfs(std::max(l, (i + x) / 2 + 1), r, i));
}
if (l <= (i + x - 1) / 2) {
max = std::max(max, dfs(l, std::min((i + x - 1) / 2, r), i));
}
if (min > max) {
min = max;
sel[l][r][x] = true;
}
}
return dp[l][r][x] = min + 1;
}
int HC(int N) {
int l = 1, r = N, x = 1;
Guess(x);
while (l < r) {
dfs(l, r, x);
const int k = (sel[l][r][x] ? r : l);
const int t = Guess(k);
if (t == 0) {
return (x + k) / 2;
}
if (t == 1) {
if (k < x) {
r = std::min(r, (k + x - 1) / 2);
} else {
l = std::max(l, (k + x) / 2 + 1);
}
} else {
if (k < x) {
l = std::max(l, (k + x) / 2 + 1);
} else {
r = std::min(r, (k + x - 1) / 2);
}
}
x = k;
}
return l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |