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 namespace std;
typedef long long ll;
ll n;
bool ask(ll n) {
bool res;
cout << "? " << n << endl;
cin >> res;
return res;
}
int main() {
cin >> n;
ll L = 1, R = n;
ll x = n / 3, dir = 0;
ask(x);
while (L < R) {
ll M = (L + R + 1) / 2;
bool r;
if (dir == 0) {
r = ask(x + M);
x += M;
}
else {
r = ask(x - M);
x -= M;
}
dir = 1 - dir;
if (r)
R = M;
else
L = M + 1;
}
cout << "= " << L << endl;
}
# | 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... |