#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define all(x) ((x).begin(),(x).end())
#define sz(x) ((int)(x).size())
bool ask(int l,int r){
cout << "? " << l << " " << r << endl;
bool ans; cin >> ans;
return ans;
}
void solve(){
int n;
cin >> n;
for(int i=1;i<200005;i++) ask(1,n);
int ans=1,p=1;
for(int i=2;i<=n;i++){
if(p>1 && ask(p-1,i)){
p--;
ans=max(ans,i-p+1);
continue;
}
while(p<i && !ask(p,i)) p++;
ans=max(ans,i-p+1);
}
cout << "! " << ans << endl;
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1;//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
987 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
987 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
918 ms |
424 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
987 ms |
432 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |