이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using ll = long long;
bool ask(const ll x) {
std::cout << "? " << x << std::endl;
bool f;
std::cin >> f;
return f;
}
int main() {
ll N;
std::cin >> N;
ll pos = 1;
{
ll x = N - 1;
int coeff = 0;
while (x > 1) {
x = (x + 1) / 2;
pos += coeff * x;
coeff = 1 - coeff;
}
}
ll ok = N, ng = 0;
int dir = 1;
ask(pos);
while (ok - ng > 1) {
const auto md = (ok + ng) / 2;
pos += dir * md;
dir = -dir;
(ask(pos) ? ok : ng) = md;
}
std::cout << "= " << ok << std::endl;
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |