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;
int n,cntq;
bool query(int le, int ri)
{
if(le<1 || ri>n || le>ri)
return 0;
if(le==ri)
return 1;
int aux;
cout<<"? "<<le<<" "<<ri<<endl;
cin>>aux;
return aux;
}
signed main()
{
cin>>n;
int mxm=1,p;
for(int i=1;i<n;i++)
{
p = mxm/2;
while(query(i-p,i+1+p))
p++;
mxm = max(mxm, 2*p);
}
for(int i=1;i<=n;i++)
{
p = (mxm+1)/2;
while(query(i-p,i+p))
p++;
mxm = max(mxm, 2*p-1);
}
cout<<"! "<<mxm<<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... |