#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())
int n;
bool ask(int l,int r){
if(l<=0 || r>n) return 0;
cout << "? " << l << " " << r << endl;
bool ans; cin >> ans;
return ans;
}
int search(int l,int r){
while(ask(l-1,r+1)){l--;r++;}
return r-l+1;
}
void solve(){
cin >> n;
int ans=1;
for(int i=2;i<=n;i++){
int u = ans/2;
if(ask(i-u,i+u)) ans=max(ans,search(i-u,i+u));
u = (ans+1)/2;
if(ask(i-u,i+u-1)) ans=max(ans,search(i-u,i+u-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 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
75 ms |
596 KB |
Output is correct |
3 |
Correct |
125 ms |
344 KB |
Output is correct |
4 |
Correct |
51 ms |
344 KB |
Output is correct |
5 |
Correct |
73 ms |
344 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
7 |
Correct |
67 ms |
344 KB |
Output is correct |
8 |
Correct |
90 ms |
344 KB |
Output is correct |
9 |
Correct |
70 ms |
344 KB |
Output is correct |
10 |
Correct |
53 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
75 ms |
596 KB |
Output is correct |
3 |
Correct |
125 ms |
344 KB |
Output is correct |
4 |
Correct |
51 ms |
344 KB |
Output is correct |
5 |
Correct |
73 ms |
344 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
7 |
Correct |
67 ms |
344 KB |
Output is correct |
8 |
Correct |
90 ms |
344 KB |
Output is correct |
9 |
Correct |
70 ms |
344 KB |
Output is correct |
10 |
Correct |
53 ms |
340 KB |
Output is correct |
11 |
Correct |
700 ms |
344 KB |
Output is correct |
12 |
Correct |
647 ms |
344 KB |
Output is correct |
13 |
Correct |
1022 ms |
344 KB |
Output is correct |
14 |
Correct |
620 ms |
344 KB |
Output is correct |
15 |
Correct |
638 ms |
344 KB |
Output is correct |
16 |
Correct |
682 ms |
344 KB |
Output is correct |
17 |
Correct |
657 ms |
344 KB |
Output is correct |
18 |
Correct |
682 ms |
344 KB |
Output is correct |
19 |
Correct |
703 ms |
344 KB |
Output is correct |
20 |
Correct |
634 ms |
344 KB |
Output is correct |
21 |
Correct |
717 ms |
344 KB |
Output is correct |
22 |
Correct |
735 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1036 ms |
344 KB |
Output is correct |
2 |
Correct |
524 ms |
344 KB |
Output is correct |
3 |
Correct |
1082 ms |
416 KB |
Output is correct |
4 |
Correct |
1082 ms |
344 KB |
Output is correct |
5 |
Correct |
1095 ms |
596 KB |
Output is correct |
6 |
Correct |
992 ms |
344 KB |
Output is correct |
7 |
Correct |
1068 ms |
344 KB |
Output is correct |
8 |
Correct |
1008 ms |
344 KB |
Output is correct |
9 |
Correct |
992 ms |
344 KB |
Output is correct |
10 |
Correct |
993 ms |
344 KB |
Output is correct |
11 |
Correct |
1109 ms |
344 KB |
Output is correct |
12 |
Correct |
1008 ms |
344 KB |
Output is correct |
13 |
Correct |
1048 ms |
344 KB |
Output is correct |
14 |
Correct |
1016 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
75 ms |
596 KB |
Output is correct |
3 |
Correct |
125 ms |
344 KB |
Output is correct |
4 |
Correct |
51 ms |
344 KB |
Output is correct |
5 |
Correct |
73 ms |
344 KB |
Output is correct |
6 |
Correct |
58 ms |
344 KB |
Output is correct |
7 |
Correct |
67 ms |
344 KB |
Output is correct |
8 |
Correct |
90 ms |
344 KB |
Output is correct |
9 |
Correct |
70 ms |
344 KB |
Output is correct |
10 |
Correct |
53 ms |
340 KB |
Output is correct |
11 |
Correct |
700 ms |
344 KB |
Output is correct |
12 |
Correct |
647 ms |
344 KB |
Output is correct |
13 |
Correct |
1022 ms |
344 KB |
Output is correct |
14 |
Correct |
620 ms |
344 KB |
Output is correct |
15 |
Correct |
638 ms |
344 KB |
Output is correct |
16 |
Correct |
682 ms |
344 KB |
Output is correct |
17 |
Correct |
657 ms |
344 KB |
Output is correct |
18 |
Correct |
682 ms |
344 KB |
Output is correct |
19 |
Correct |
703 ms |
344 KB |
Output is correct |
20 |
Correct |
634 ms |
344 KB |
Output is correct |
21 |
Correct |
717 ms |
344 KB |
Output is correct |
22 |
Correct |
735 ms |
344 KB |
Output is correct |
23 |
Correct |
1036 ms |
344 KB |
Output is correct |
24 |
Correct |
524 ms |
344 KB |
Output is correct |
25 |
Correct |
1082 ms |
416 KB |
Output is correct |
26 |
Correct |
1082 ms |
344 KB |
Output is correct |
27 |
Correct |
1095 ms |
596 KB |
Output is correct |
28 |
Correct |
992 ms |
344 KB |
Output is correct |
29 |
Correct |
1068 ms |
344 KB |
Output is correct |
30 |
Correct |
1008 ms |
344 KB |
Output is correct |
31 |
Correct |
992 ms |
344 KB |
Output is correct |
32 |
Correct |
993 ms |
344 KB |
Output is correct |
33 |
Correct |
1109 ms |
344 KB |
Output is correct |
34 |
Correct |
1008 ms |
344 KB |
Output is correct |
35 |
Correct |
1048 ms |
344 KB |
Output is correct |
36 |
Correct |
1016 ms |
344 KB |
Output is correct |
37 |
Correct |
1002 ms |
344 KB |
Output is correct |
38 |
Runtime error |
1051 ms |
424 KB |
Execution killed with signal 13 |
39 |
Halted |
0 ms |
0 KB |
- |