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>
typedef long long ll;
using namespace std;
ll a, b, c, d, e, n, m, l, r, mid, ind, pos;
bool barla(long long k)
{
bool ret;
cout<<"? "<<k<<endl;
cin>>ret;
return ret;
}
int main()
{
cin>>n;
l=1; r=n;
pos=-1; ind=pos;
long long bir=1;
while (l<r)
{
mid=(l+r-1)/2;
ind=ind+(bir*mid);
pos=min(pos, ind);
l=mid+1;
bir=bir*(-1);
}
pos=abs(pos);
barla(pos);
l=1; r=n; bir=1;
bool hakyky=false;
while (l<r)
{
mid=(l+r-1)/2;
pos=pos+(bir*mid);
hakyky=barla(pos);
if (hakyky) r=mid;
else l=mid+1;
bir=bir*(-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... |