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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool ask(int l,int r){
cout<<"? "<<l<<" "<<r<<endl;
bool flag;
cin>>flag;
return flag;
}
int main(){
int n;
cin>>n;
int ans=0;
for(int i=2;i<=n+1;i++){
int l,r;
if((i-ans+1)%2==0) l=(i-ans+1)/2-1;
else l=(i-ans+1)/2;
r=i-l;
while(l>=1&&r<=n&&ask(l,r)){
l--;
r++;
}
l++;
r--;
ans=max(ans,r-l+1);
}
cout<<"! "<<ans<<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... |