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;
int Ask(int x){
cout << "? " << x << endl;
int res;
cin >> res;
return res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
ll l = 1, r = n - 1, start = 1, cur = -1, dir = -1;
while (l <= r){
int mid = (l + r) >> 1;
cur += mid * dir;
dir *= -1;
l = mid + 1;
start = max(start, -cur);
}
l = 1, r = n - 1, cur = start, dir = -1;
Ask(start);
ll answer = n, delta = 0;
while (l <= r){
int mid = (l + r) >> 1;
cur += (mid + delta) * dir;
dir *= -1;
if (Ask(cur)){
answer = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
cout << "= " << answer << 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... |