#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define all(x) ((x).begin(),(x).end())
#define sz(x) ((int)(x).size())
int ask(int l,int r){
cout << "? " << l << " " << r << endl << flush;
int ans; cin >> ans;
return ans;
}
void solve(){
int n;
cin >> n;
int ans=1;
int p = 1;
for(int i=2;i<=n;i++){
if(p>=2 && ask(p-1,i)){
p--;
ans=max(ans,i-p+1);
continue;
}
while(p<i && ask(p,i)==0) p++;
ans=max(ans,i-p+1);
}
cout << "! " << ans << endl << flush;
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1;//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
65 ms |
344 KB |
Output is correct |
3 |
Correct |
69 ms |
344 KB |
Output is correct |
4 |
Correct |
86 ms |
344 KB |
Output is correct |
5 |
Correct |
92 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
57 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
596 KB |
Output is correct |
9 |
Correct |
87 ms |
344 KB |
Output is correct |
10 |
Correct |
72 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
65 ms |
344 KB |
Output is correct |
3 |
Correct |
69 ms |
344 KB |
Output is correct |
4 |
Correct |
86 ms |
344 KB |
Output is correct |
5 |
Correct |
92 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
57 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
596 KB |
Output is correct |
9 |
Correct |
87 ms |
344 KB |
Output is correct |
10 |
Correct |
72 ms |
344 KB |
Output is correct |
11 |
Correct |
916 ms |
344 KB |
Output is correct |
12 |
Correct |
612 ms |
344 KB |
Output is correct |
13 |
Correct |
624 ms |
344 KB |
Output is correct |
14 |
Correct |
900 ms |
344 KB |
Output is correct |
15 |
Correct |
661 ms |
344 KB |
Output is correct |
16 |
Correct |
919 ms |
344 KB |
Output is correct |
17 |
Correct |
620 ms |
344 KB |
Output is correct |
18 |
Correct |
807 ms |
344 KB |
Output is correct |
19 |
Correct |
909 ms |
344 KB |
Output is correct |
20 |
Correct |
758 ms |
344 KB |
Output is correct |
21 |
Correct |
696 ms |
344 KB |
Output is correct |
22 |
Correct |
633 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1020 ms |
504 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
344 KB |
Output is correct |
2 |
Correct |
65 ms |
344 KB |
Output is correct |
3 |
Correct |
69 ms |
344 KB |
Output is correct |
4 |
Correct |
86 ms |
344 KB |
Output is correct |
5 |
Correct |
92 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
57 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
596 KB |
Output is correct |
9 |
Correct |
87 ms |
344 KB |
Output is correct |
10 |
Correct |
72 ms |
344 KB |
Output is correct |
11 |
Correct |
916 ms |
344 KB |
Output is correct |
12 |
Correct |
612 ms |
344 KB |
Output is correct |
13 |
Correct |
624 ms |
344 KB |
Output is correct |
14 |
Correct |
900 ms |
344 KB |
Output is correct |
15 |
Correct |
661 ms |
344 KB |
Output is correct |
16 |
Correct |
919 ms |
344 KB |
Output is correct |
17 |
Correct |
620 ms |
344 KB |
Output is correct |
18 |
Correct |
807 ms |
344 KB |
Output is correct |
19 |
Correct |
909 ms |
344 KB |
Output is correct |
20 |
Correct |
758 ms |
344 KB |
Output is correct |
21 |
Correct |
696 ms |
344 KB |
Output is correct |
22 |
Correct |
633 ms |
344 KB |
Output is correct |
23 |
Runtime error |
1020 ms |
504 KB |
Execution killed with signal 13 |
24 |
Halted |
0 ms |
0 KB |
- |