#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin>>n;
int ans=1;
for (int i=1; i<n; i++) {
cout<<"? "<<i<<" "<<i+1<<endl;
cout.flush();
int a; cin>>a;
if (a) {
ans=max(ans,2);
int l=i,r=i+1;
while (true) {
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (a) {
ans=max(ans,r-l+1);
} else break;
}
}
}
for (int i=1; i<n-1; i++) {
cout<<"? "<<i<<" "<<i+2<<endl;
cout.flush();
int a; cin>>a;
if (a) {
ans=max(ans,3);
int l=i,r=i+2;
while (true) {
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (a) {
ans=max(ans,r-l+1);
} else break;
}
}
}
cout<<"! "<<ans<<endl;
cout.flush();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
165 ms |
344 KB |
Output is correct |
2 |
Correct |
82 ms |
344 KB |
Output is correct |
3 |
Correct |
88 ms |
344 KB |
Output is correct |
4 |
Correct |
888 ms |
344 KB |
Output is correct |
5 |
Correct |
548 ms |
344 KB |
Output is correct |
6 |
Correct |
329 ms |
344 KB |
Output is correct |
7 |
Runtime error |
1033 ms |
408 KB |
Execution killed with signal 13 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
165 ms |
344 KB |
Output is correct |
2 |
Correct |
82 ms |
344 KB |
Output is correct |
3 |
Correct |
88 ms |
344 KB |
Output is correct |
4 |
Correct |
888 ms |
344 KB |
Output is correct |
5 |
Correct |
548 ms |
344 KB |
Output is correct |
6 |
Correct |
329 ms |
344 KB |
Output is correct |
7 |
Runtime error |
1033 ms |
408 KB |
Execution killed with signal 13 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1109 ms |
416 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
165 ms |
344 KB |
Output is correct |
2 |
Correct |
82 ms |
344 KB |
Output is correct |
3 |
Correct |
88 ms |
344 KB |
Output is correct |
4 |
Correct |
888 ms |
344 KB |
Output is correct |
5 |
Correct |
548 ms |
344 KB |
Output is correct |
6 |
Correct |
329 ms |
344 KB |
Output is correct |
7 |
Runtime error |
1033 ms |
408 KB |
Execution killed with signal 13 |
8 |
Halted |
0 ms |
0 KB |
- |