#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;
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
344 KB |
Output is correct |
2 |
Correct |
68 ms |
344 KB |
Output is correct |
3 |
Correct |
75 ms |
344 KB |
Output is correct |
4 |
Correct |
116 ms |
344 KB |
Output is correct |
5 |
Correct |
81 ms |
344 KB |
Output is correct |
6 |
Correct |
82 ms |
344 KB |
Output is correct |
7 |
Correct |
74 ms |
596 KB |
Output is correct |
8 |
Correct |
97 ms |
344 KB |
Output is correct |
9 |
Correct |
93 ms |
344 KB |
Output is correct |
10 |
Correct |
76 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
344 KB |
Output is correct |
2 |
Correct |
68 ms |
344 KB |
Output is correct |
3 |
Correct |
75 ms |
344 KB |
Output is correct |
4 |
Correct |
116 ms |
344 KB |
Output is correct |
5 |
Correct |
81 ms |
344 KB |
Output is correct |
6 |
Correct |
82 ms |
344 KB |
Output is correct |
7 |
Correct |
74 ms |
596 KB |
Output is correct |
8 |
Correct |
97 ms |
344 KB |
Output is correct |
9 |
Correct |
93 ms |
344 KB |
Output is correct |
10 |
Correct |
76 ms |
344 KB |
Output is correct |
11 |
Correct |
928 ms |
344 KB |
Output is correct |
12 |
Correct |
659 ms |
344 KB |
Output is correct |
13 |
Correct |
648 ms |
344 KB |
Output is correct |
14 |
Correct |
988 ms |
344 KB |
Output is correct |
15 |
Correct |
724 ms |
344 KB |
Output is correct |
16 |
Correct |
1002 ms |
344 KB |
Output is correct |
17 |
Correct |
621 ms |
344 KB |
Output is correct |
18 |
Correct |
848 ms |
344 KB |
Output is correct |
19 |
Correct |
926 ms |
344 KB |
Output is correct |
20 |
Correct |
825 ms |
344 KB |
Output is correct |
21 |
Correct |
757 ms |
344 KB |
Output is correct |
22 |
Correct |
630 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
992 ms |
428 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
344 KB |
Output is correct |
2 |
Correct |
68 ms |
344 KB |
Output is correct |
3 |
Correct |
75 ms |
344 KB |
Output is correct |
4 |
Correct |
116 ms |
344 KB |
Output is correct |
5 |
Correct |
81 ms |
344 KB |
Output is correct |
6 |
Correct |
82 ms |
344 KB |
Output is correct |
7 |
Correct |
74 ms |
596 KB |
Output is correct |
8 |
Correct |
97 ms |
344 KB |
Output is correct |
9 |
Correct |
93 ms |
344 KB |
Output is correct |
10 |
Correct |
76 ms |
344 KB |
Output is correct |
11 |
Correct |
928 ms |
344 KB |
Output is correct |
12 |
Correct |
659 ms |
344 KB |
Output is correct |
13 |
Correct |
648 ms |
344 KB |
Output is correct |
14 |
Correct |
988 ms |
344 KB |
Output is correct |
15 |
Correct |
724 ms |
344 KB |
Output is correct |
16 |
Correct |
1002 ms |
344 KB |
Output is correct |
17 |
Correct |
621 ms |
344 KB |
Output is correct |
18 |
Correct |
848 ms |
344 KB |
Output is correct |
19 |
Correct |
926 ms |
344 KB |
Output is correct |
20 |
Correct |
825 ms |
344 KB |
Output is correct |
21 |
Correct |
757 ms |
344 KB |
Output is correct |
22 |
Correct |
630 ms |
344 KB |
Output is correct |
23 |
Runtime error |
992 ms |
428 KB |
Execution killed with signal 13 |
24 |
Halted |
0 ms |
0 KB |
- |