#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int inf = 1e15 + 10;
const int N = 3e5 + 5;
bool query(int l, int r){
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
bool pal;
cin>>pal;
return pal;
}
int32_t main(){
int n;
cin>>n;
int oddmx = 1, evenmx = 0;
for(int i = 1; i <= n; i++){
int st = oddmx + 2;
for(int len = st; len <= n; len += 2){
int l = i - (len - 1)/2, r = i + (len - 1)/2;
if(l < 1 || r > n) break;
bool pal = query(l, r);
if(!pal) break;
oddmx = len;
}
}
for(int i = 1; i <= n; i++){
int st = max(oddmx + 1, evenmx + 2);
for(int len = st; len <= n; len += 2){
int l = i - len/2 + 1, r = i + len/2;
if(l < 1 || r > n) break;
bool pal = query(l, r);
if(!pal) break;
evenmx = len;
}
}
int ans = max(oddmx, evenmx);
cout<<"! "<<ans<<endl;
cout.flush();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
336 KB |
Output is correct |
2 |
Correct |
278 ms |
336 KB |
Output is correct |
3 |
Correct |
254 ms |
336 KB |
Output is correct |
4 |
Correct |
292 ms |
336 KB |
Output is correct |
5 |
Correct |
239 ms |
336 KB |
Output is correct |
6 |
Correct |
247 ms |
336 KB |
Output is correct |
7 |
Correct |
136 ms |
336 KB |
Output is correct |
8 |
Correct |
122 ms |
508 KB |
Output is correct |
9 |
Correct |
218 ms |
336 KB |
Output is correct |
10 |
Correct |
259 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
336 KB |
Output is correct |
2 |
Correct |
278 ms |
336 KB |
Output is correct |
3 |
Correct |
254 ms |
336 KB |
Output is correct |
4 |
Correct |
292 ms |
336 KB |
Output is correct |
5 |
Correct |
239 ms |
336 KB |
Output is correct |
6 |
Correct |
247 ms |
336 KB |
Output is correct |
7 |
Correct |
136 ms |
336 KB |
Output is correct |
8 |
Correct |
122 ms |
508 KB |
Output is correct |
9 |
Correct |
218 ms |
336 KB |
Output is correct |
10 |
Correct |
259 ms |
336 KB |
Output is correct |
11 |
Correct |
2527 ms |
336 KB |
Output is correct |
12 |
Correct |
2470 ms |
336 KB |
Output is correct |
13 |
Correct |
2558 ms |
336 KB |
Output is correct |
14 |
Correct |
2364 ms |
336 KB |
Output is correct |
15 |
Correct |
2386 ms |
336 KB |
Output is correct |
16 |
Correct |
1246 ms |
336 KB |
Output is correct |
17 |
Correct |
1277 ms |
336 KB |
Output is correct |
18 |
Correct |
2566 ms |
336 KB |
Output is correct |
19 |
Correct |
1235 ms |
336 KB |
Output is correct |
20 |
Correct |
2149 ms |
336 KB |
Output is correct |
21 |
Correct |
2200 ms |
336 KB |
Output is correct |
22 |
Correct |
2495 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3923 ms |
336 KB |
Output is correct |
2 |
Correct |
970 ms |
336 KB |
Output is correct |
3 |
Correct |
3763 ms |
336 KB |
Output is correct |
4 |
Correct |
2344 ms |
336 KB |
Output is correct |
5 |
Correct |
1754 ms |
336 KB |
Output is correct |
6 |
Correct |
3824 ms |
336 KB |
Output is correct |
7 |
Correct |
1948 ms |
336 KB |
Output is correct |
8 |
Correct |
3912 ms |
336 KB |
Output is correct |
9 |
Correct |
3822 ms |
336 KB |
Output is correct |
10 |
Correct |
3859 ms |
336 KB |
Output is correct |
11 |
Correct |
1863 ms |
336 KB |
Output is correct |
12 |
Correct |
1926 ms |
336 KB |
Output is correct |
13 |
Correct |
3740 ms |
336 KB |
Output is correct |
14 |
Correct |
3885 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
336 KB |
Output is correct |
2 |
Correct |
278 ms |
336 KB |
Output is correct |
3 |
Correct |
254 ms |
336 KB |
Output is correct |
4 |
Correct |
292 ms |
336 KB |
Output is correct |
5 |
Correct |
239 ms |
336 KB |
Output is correct |
6 |
Correct |
247 ms |
336 KB |
Output is correct |
7 |
Correct |
136 ms |
336 KB |
Output is correct |
8 |
Correct |
122 ms |
508 KB |
Output is correct |
9 |
Correct |
218 ms |
336 KB |
Output is correct |
10 |
Correct |
259 ms |
336 KB |
Output is correct |
11 |
Correct |
2527 ms |
336 KB |
Output is correct |
12 |
Correct |
2470 ms |
336 KB |
Output is correct |
13 |
Correct |
2558 ms |
336 KB |
Output is correct |
14 |
Correct |
2364 ms |
336 KB |
Output is correct |
15 |
Correct |
2386 ms |
336 KB |
Output is correct |
16 |
Correct |
1246 ms |
336 KB |
Output is correct |
17 |
Correct |
1277 ms |
336 KB |
Output is correct |
18 |
Correct |
2566 ms |
336 KB |
Output is correct |
19 |
Correct |
1235 ms |
336 KB |
Output is correct |
20 |
Correct |
2149 ms |
336 KB |
Output is correct |
21 |
Correct |
2200 ms |
336 KB |
Output is correct |
22 |
Correct |
2495 ms |
336 KB |
Output is correct |
23 |
Correct |
3923 ms |
336 KB |
Output is correct |
24 |
Correct |
970 ms |
336 KB |
Output is correct |
25 |
Correct |
3763 ms |
336 KB |
Output is correct |
26 |
Correct |
2344 ms |
336 KB |
Output is correct |
27 |
Correct |
1754 ms |
336 KB |
Output is correct |
28 |
Correct |
3824 ms |
336 KB |
Output is correct |
29 |
Correct |
1948 ms |
336 KB |
Output is correct |
30 |
Correct |
3912 ms |
336 KB |
Output is correct |
31 |
Correct |
3822 ms |
336 KB |
Output is correct |
32 |
Correct |
3859 ms |
336 KB |
Output is correct |
33 |
Correct |
1863 ms |
336 KB |
Output is correct |
34 |
Correct |
1926 ms |
336 KB |
Output is correct |
35 |
Correct |
3740 ms |
336 KB |
Output is correct |
36 |
Correct |
3885 ms |
336 KB |
Output is correct |
37 |
Correct |
3859 ms |
336 KB |
Output is correct |
38 |
Correct |
3863 ms |
336 KB |
Output is correct |
39 |
Correct |
3811 ms |
336 KB |
Output is correct |
40 |
Correct |
3743 ms |
336 KB |
Output is correct |
41 |
Correct |
3685 ms |
336 KB |
Output is correct |
42 |
Correct |
2452 ms |
336 KB |
Output is correct |
43 |
Correct |
1941 ms |
336 KB |
Output is correct |
44 |
Correct |
3878 ms |
336 KB |
Output is correct |
45 |
Correct |
1948 ms |
336 KB |
Output is correct |
46 |
Correct |
3768 ms |
336 KB |
Output is correct |
47 |
Correct |
3795 ms |
336 KB |
Output is correct |
48 |
Correct |
3784 ms |
336 KB |
Output is correct |
49 |
Correct |
1922 ms |
336 KB |
Output is correct |
50 |
Correct |
2044 ms |
336 KB |
Output is correct |
51 |
Correct |
3980 ms |
336 KB |
Output is correct |
52 |
Correct |
3842 ms |
336 KB |
Output is correct |