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;
#define int ll
bool query(int i)
{
cout << "? " << i << endl;
cin >> i;
return i;
}
signed main()
{
int n;
cin >> n;
int i = 0, c = 0, l = 1, r = n, d = -1;
while(l < r)
{
l = (l + r - 1) / 2;
c += d * l;
l ++;
i = max(i, 1LL - c);
d *= -1;
}
query(i);
l = 1, r = n, d = -1;
while(l < r)
{
int m = (l + r - 1) / 2;
i += d * m;
if(query(i))
r = m;
else
l = m + 1;
d *= -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... |