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;
using ll = long long;
bool query(ll i) {
cout << "? " << i << endl;
cin >> i;
return i;
}
int main() {
ll N; cin >> N;
ll i = 0, c = 0, l = 1, r = N, d = -1;
for(; l < r; d = -d) {
l = (l + r - 1) >> 1;
i = max(i, ll(1) - (c += d * l++));
}
query(i);
l = 1, r = N, d = -1;
for(; l < r; d = -d) {
ll m = (l + r - 1) >> 1;
if(query(i += d * m)) 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... |