#include <bits/stdc++.h>
using namespace std;
bool ask(int l, int r){
cout << "? " << l << ' ' << r;
cout << flush;
int t; cin >> t;
return t;
}
void answer(int L){
cout << "! " << L;
cout << flush;
}
void solve(){
int n; cin >> n;
int ans = 1;
for (int i = 1; i <= n; ++ i){
while (i - ans >= 1 && i + ans <= n && ask(i - ans, i + ans)) ++ ans;
}
int res = 2 * ans - 1;
for (int i = 1; i <= n; ++ i){
while (i - ans >= 1 && i + ans + 1 <= n && ask(i - ans, i + ans + 1)) ++ ans, res = max(res, 2 * ans - 2);
}
answer(res);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |