#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin>>n;
int ans1=1;
for (int i=1; i<=n; i++) {
int l=i-(ans1+2)/2,r=i+(ans1+2)/2;
if (l<1||r>n) continue;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
int a; cin>>a;
if (a) {
ans1=max(ans1,r-l+1);
while (true) {
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (!a) break;
}
}
}
int ans2=0;
for (int i=1; i<=n; i++) {
int l=i-(ans2+2)/2+1,r=i+(ans2+2)/2;
if (l<1||r>n) continue;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
int a; cin>>a;
if (a) {
ans2=max(ans2,r-l+1);
while (true) {
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (!a) break;
}
}
}
cout<<"! "<<max(ans1,ans2)<<endl;
cout.flush();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
344 KB |
L = 25, expected 30 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
344 KB |
L = 25, expected 30 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1152 ms |
408 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
344 KB |
L = 25, expected 30 |
2 |
Halted |
0 ms |
0 KB |
- |