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 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 = (N + 3) / 4;
ll ok = N, ng = 0;
int dir = 1;
ask(pos);
ll last = 0;
while (ok - ng > 1) {
ll md = (ok + ng) / 2;
if ((ok + ng) % 2 == 1 and last == ng) {
md += 1;
}
last = md;
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... |