#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 |
1 |
Correct |
28 ms |
344 KB |
Output is correct |
2 |
Incorrect |
33 ms |
344 KB |
L = 5, expected 7 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
344 KB |
Output is correct |
2 |
Incorrect |
33 ms |
344 KB |
L = 5, expected 7 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
530 ms |
344 KB |
Output is correct |
2 |
Correct |
498 ms |
344 KB |
Output is correct |
3 |
Correct |
503 ms |
344 KB |
Output is correct |
4 |
Incorrect |
734 ms |
344 KB |
L = 45510, expected 72705 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
344 KB |
Output is correct |
2 |
Incorrect |
33 ms |
344 KB |
L = 5, expected 7 |
3 |
Halted |
0 ms |
0 KB |
- |