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 <iostream>
using namespace std;
int n, res = 0;
void ask(int x) {
cout << "? " << x << "\n";
cout.flush();
cin >> res;
}
int cb() {
int l = 1, r = n, sol = -1;
while (l <= r) {
int mid = (l + r) / 2;
ask(mid);
if (res == 0) {
sol = mid;
break;
} else if (res == 1) {
r = mid - 1;
} else {
l = mid + 1;
}
}
return sol;
}
int main() {
cin >> n;
int answer = cb();
cout << "= " << answer;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |