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>
#define int long long
using namespace std;
int R[2][200000];
int32_t main()
{
//cin.tie(0);
//cout.tie(0);
//ios_base::sync_with_stdio(0);
int n;
cin>>n;
int maxx=0;
for(int j=0;j<=1;j++)
{
R[j][0]=0;
int rp=0;
int i=1;
while(i<=n)
{
while(i-rp-1>=1 && i+j+rp<=n)
{
cout<<"? "<<i-rp-1<<" "<<i+j+rp<<"\n";
int co;
cin>>co;
if(co==1)
rp++;
else break;
}
R[j][i]=rp;
int k=1;
while((R[j][i-k]!=rp-k)&&(k<rp))
{
R[j][i+k]=min(R[j][i-k],rp-k);
k++;
}
rp=max(rp-k,0LL);
i+=k;
}
}
for(int i=0;i<=1;i++)
for(int j=0;j<=n;j++)
maxx=max(maxx,R[i][j]*2+i);
cout<<"! "<<maxx;
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... |