#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin>>n;
int ans1=1;
for (int i=1; i<=n; i++) {
if (ans1==n) break;
int l=i-(ans1+2)/2,r=i+(ans1+2)/2;
if (l<1||r>n) continue;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
int a; cin>>a;
if (a) {
while (true) {
ans1=max(ans1,r-l+1);
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (!a) break;
}
}
}
int ans2=0;
for (int i=1; i<=n; i++) {
if (ans1==n||ans2==n) break;
int l=i-(ans2+2)/2+1,r=i+(ans2+2)/2;
if (l<1||r>n) continue;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
int a; cin>>a;
if (a) {
while (true) {
ans2=max(ans2,r-l+1);
l--; r++;
if (l<1||r>n) break;
cout<<"? "<<l<<" "<<r<<endl;
cout.flush();
cin>>a;
if (!a) break;
}
}
}
cout<<"! "<<max(ans1,ans2)<<endl;
cout.flush();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
344 KB |
Output is correct |
2 |
Correct |
73 ms |
344 KB |
Output is correct |
3 |
Correct |
63 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
69 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
95 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
78 ms |
344 KB |
Output is correct |
10 |
Correct |
81 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
344 KB |
Output is correct |
2 |
Correct |
73 ms |
344 KB |
Output is correct |
3 |
Correct |
63 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
69 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
95 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
78 ms |
344 KB |
Output is correct |
10 |
Correct |
81 ms |
340 KB |
Output is correct |
11 |
Correct |
730 ms |
344 KB |
Output is correct |
12 |
Correct |
799 ms |
344 KB |
Output is correct |
13 |
Correct |
705 ms |
344 KB |
Output is correct |
14 |
Correct |
719 ms |
344 KB |
Output is correct |
15 |
Correct |
743 ms |
344 KB |
Output is correct |
16 |
Correct |
788 ms |
344 KB |
Output is correct |
17 |
Correct |
740 ms |
344 KB |
Output is correct |
18 |
Correct |
783 ms |
344 KB |
Output is correct |
19 |
Correct |
704 ms |
344 KB |
Output is correct |
20 |
Correct |
656 ms |
344 KB |
Output is correct |
21 |
Correct |
756 ms |
344 KB |
Output is correct |
22 |
Correct |
736 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1140 ms |
344 KB |
Output is correct |
2 |
Correct |
867 ms |
344 KB |
Output is correct |
3 |
Correct |
1182 ms |
340 KB |
Output is correct |
4 |
Correct |
1126 ms |
344 KB |
Output is correct |
5 |
Correct |
1130 ms |
344 KB |
Output is correct |
6 |
Correct |
1209 ms |
344 KB |
Output is correct |
7 |
Correct |
1215 ms |
340 KB |
Output is correct |
8 |
Correct |
1128 ms |
344 KB |
Output is correct |
9 |
Correct |
1186 ms |
344 KB |
Output is correct |
10 |
Correct |
1166 ms |
344 KB |
Output is correct |
11 |
Correct |
1135 ms |
344 KB |
Output is correct |
12 |
Correct |
1121 ms |
344 KB |
Output is correct |
13 |
Correct |
1130 ms |
344 KB |
Output is correct |
14 |
Correct |
1075 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
344 KB |
Output is correct |
2 |
Correct |
73 ms |
344 KB |
Output is correct |
3 |
Correct |
63 ms |
344 KB |
Output is correct |
4 |
Correct |
99 ms |
344 KB |
Output is correct |
5 |
Correct |
69 ms |
344 KB |
Output is correct |
6 |
Correct |
93 ms |
344 KB |
Output is correct |
7 |
Correct |
95 ms |
344 KB |
Output is correct |
8 |
Correct |
86 ms |
344 KB |
Output is correct |
9 |
Correct |
78 ms |
344 KB |
Output is correct |
10 |
Correct |
81 ms |
340 KB |
Output is correct |
11 |
Correct |
730 ms |
344 KB |
Output is correct |
12 |
Correct |
799 ms |
344 KB |
Output is correct |
13 |
Correct |
705 ms |
344 KB |
Output is correct |
14 |
Correct |
719 ms |
344 KB |
Output is correct |
15 |
Correct |
743 ms |
344 KB |
Output is correct |
16 |
Correct |
788 ms |
344 KB |
Output is correct |
17 |
Correct |
740 ms |
344 KB |
Output is correct |
18 |
Correct |
783 ms |
344 KB |
Output is correct |
19 |
Correct |
704 ms |
344 KB |
Output is correct |
20 |
Correct |
656 ms |
344 KB |
Output is correct |
21 |
Correct |
756 ms |
344 KB |
Output is correct |
22 |
Correct |
736 ms |
344 KB |
Output is correct |
23 |
Correct |
1140 ms |
344 KB |
Output is correct |
24 |
Correct |
867 ms |
344 KB |
Output is correct |
25 |
Correct |
1182 ms |
340 KB |
Output is correct |
26 |
Correct |
1126 ms |
344 KB |
Output is correct |
27 |
Correct |
1130 ms |
344 KB |
Output is correct |
28 |
Correct |
1209 ms |
344 KB |
Output is correct |
29 |
Correct |
1215 ms |
340 KB |
Output is correct |
30 |
Correct |
1128 ms |
344 KB |
Output is correct |
31 |
Correct |
1186 ms |
344 KB |
Output is correct |
32 |
Correct |
1166 ms |
344 KB |
Output is correct |
33 |
Correct |
1135 ms |
344 KB |
Output is correct |
34 |
Correct |
1121 ms |
344 KB |
Output is correct |
35 |
Correct |
1130 ms |
344 KB |
Output is correct |
36 |
Correct |
1075 ms |
344 KB |
Output is correct |
37 |
Correct |
1143 ms |
344 KB |
Output is correct |
38 |
Correct |
1203 ms |
344 KB |
Output is correct |
39 |
Correct |
1168 ms |
344 KB |
Output is correct |
40 |
Correct |
1148 ms |
344 KB |
Output is correct |
41 |
Correct |
1121 ms |
344 KB |
Output is correct |
42 |
Correct |
1150 ms |
344 KB |
Output is correct |
43 |
Correct |
1132 ms |
344 KB |
Output is correct |
44 |
Correct |
1006 ms |
344 KB |
Output is correct |
45 |
Correct |
1054 ms |
344 KB |
Output is correct |
46 |
Correct |
1028 ms |
344 KB |
Output is correct |
47 |
Correct |
1087 ms |
344 KB |
Output is correct |
48 |
Correct |
1069 ms |
344 KB |
Output is correct |
49 |
Correct |
1101 ms |
344 KB |
Output is correct |
50 |
Correct |
1090 ms |
344 KB |
Output is correct |
51 |
Correct |
1006 ms |
344 KB |
Output is correct |
52 |
Correct |
1099 ms |
344 KB |
Output is correct |