#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n;
cin >> n;
int sz=2;
for (int i=1;i<=n;i++){
int x=1;
while (x){
int l=i-sz/2+1,r=i+sz/2;
if (l > 0 && r <= n){
cout << "? " << l << " " << r << endl;
cin >> x;
if (x) sz+=2;
}
else x=0;
}
}
int sz2=3;
for (int i=1;i<=n;i++){
int x=1;
while (x){
int l=i-sz2/2,r=i+sz2/2;
if (l > 0 && r <= n){
cout << "? " << l << " " << r << endl;
cin >> x;
if (x) sz2+=2;
}
else x=0;
}
}
cout << "! " << max(sz,sz2)-2 << "\n";
return 0;
}
//0 1 1 2 2 3 1
//2 4 1 2 2 5 1
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
208 KB |
Output is correct |
2 |
Correct |
157 ms |
208 KB |
Output is correct |
3 |
Correct |
142 ms |
208 KB |
Output is correct |
4 |
Correct |
113 ms |
208 KB |
Output is correct |
5 |
Correct |
121 ms |
208 KB |
Output is correct |
6 |
Correct |
135 ms |
208 KB |
Output is correct |
7 |
Correct |
123 ms |
208 KB |
Output is correct |
8 |
Correct |
110 ms |
208 KB |
Output is correct |
9 |
Correct |
144 ms |
208 KB |
Output is correct |
10 |
Correct |
162 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
208 KB |
Output is correct |
2 |
Correct |
157 ms |
208 KB |
Output is correct |
3 |
Correct |
142 ms |
208 KB |
Output is correct |
4 |
Correct |
113 ms |
208 KB |
Output is correct |
5 |
Correct |
121 ms |
208 KB |
Output is correct |
6 |
Correct |
135 ms |
208 KB |
Output is correct |
7 |
Correct |
123 ms |
208 KB |
Output is correct |
8 |
Correct |
110 ms |
208 KB |
Output is correct |
9 |
Correct |
144 ms |
208 KB |
Output is correct |
10 |
Correct |
162 ms |
208 KB |
Output is correct |
11 |
Correct |
1035 ms |
208 KB |
Output is correct |
12 |
Correct |
802 ms |
208 KB |
Output is correct |
13 |
Correct |
684 ms |
316 KB |
Output is correct |
14 |
Correct |
768 ms |
208 KB |
Output is correct |
15 |
Correct |
654 ms |
208 KB |
Output is correct |
16 |
Correct |
897 ms |
208 KB |
Output is correct |
17 |
Correct |
938 ms |
208 KB |
Output is correct |
18 |
Correct |
877 ms |
308 KB |
Output is correct |
19 |
Correct |
917 ms |
208 KB |
Output is correct |
20 |
Correct |
1129 ms |
208 KB |
Output is correct |
21 |
Correct |
966 ms |
208 KB |
Output is correct |
22 |
Correct |
885 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1944 ms |
208 KB |
Output is correct |
2 |
Correct |
1415 ms |
312 KB |
Output is correct |
3 |
Correct |
1728 ms |
208 KB |
Output is correct |
4 |
Correct |
1665 ms |
208 KB |
Output is correct |
5 |
Correct |
1489 ms |
208 KB |
Output is correct |
6 |
Correct |
1537 ms |
208 KB |
Output is correct |
7 |
Correct |
1708 ms |
208 KB |
Output is correct |
8 |
Correct |
1262 ms |
208 KB |
Output is correct |
9 |
Correct |
1374 ms |
316 KB |
Output is correct |
10 |
Correct |
1614 ms |
208 KB |
Output is correct |
11 |
Correct |
1609 ms |
208 KB |
Output is correct |
12 |
Correct |
1457 ms |
208 KB |
Output is correct |
13 |
Correct |
1883 ms |
208 KB |
Output is correct |
14 |
Correct |
1321 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
208 KB |
Output is correct |
2 |
Correct |
157 ms |
208 KB |
Output is correct |
3 |
Correct |
142 ms |
208 KB |
Output is correct |
4 |
Correct |
113 ms |
208 KB |
Output is correct |
5 |
Correct |
121 ms |
208 KB |
Output is correct |
6 |
Correct |
135 ms |
208 KB |
Output is correct |
7 |
Correct |
123 ms |
208 KB |
Output is correct |
8 |
Correct |
110 ms |
208 KB |
Output is correct |
9 |
Correct |
144 ms |
208 KB |
Output is correct |
10 |
Correct |
162 ms |
208 KB |
Output is correct |
11 |
Correct |
1035 ms |
208 KB |
Output is correct |
12 |
Correct |
802 ms |
208 KB |
Output is correct |
13 |
Correct |
684 ms |
316 KB |
Output is correct |
14 |
Correct |
768 ms |
208 KB |
Output is correct |
15 |
Correct |
654 ms |
208 KB |
Output is correct |
16 |
Correct |
897 ms |
208 KB |
Output is correct |
17 |
Correct |
938 ms |
208 KB |
Output is correct |
18 |
Correct |
877 ms |
308 KB |
Output is correct |
19 |
Correct |
917 ms |
208 KB |
Output is correct |
20 |
Correct |
1129 ms |
208 KB |
Output is correct |
21 |
Correct |
966 ms |
208 KB |
Output is correct |
22 |
Correct |
885 ms |
208 KB |
Output is correct |
23 |
Correct |
1944 ms |
208 KB |
Output is correct |
24 |
Correct |
1415 ms |
312 KB |
Output is correct |
25 |
Correct |
1728 ms |
208 KB |
Output is correct |
26 |
Correct |
1665 ms |
208 KB |
Output is correct |
27 |
Correct |
1489 ms |
208 KB |
Output is correct |
28 |
Correct |
1537 ms |
208 KB |
Output is correct |
29 |
Correct |
1708 ms |
208 KB |
Output is correct |
30 |
Correct |
1262 ms |
208 KB |
Output is correct |
31 |
Correct |
1374 ms |
316 KB |
Output is correct |
32 |
Correct |
1614 ms |
208 KB |
Output is correct |
33 |
Correct |
1609 ms |
208 KB |
Output is correct |
34 |
Correct |
1457 ms |
208 KB |
Output is correct |
35 |
Correct |
1883 ms |
208 KB |
Output is correct |
36 |
Correct |
1321 ms |
208 KB |
Output is correct |
37 |
Correct |
1576 ms |
208 KB |
Output is correct |
38 |
Correct |
1607 ms |
208 KB |
Output is correct |
39 |
Correct |
1204 ms |
336 KB |
Output is correct |
40 |
Correct |
1737 ms |
208 KB |
Output is correct |
41 |
Correct |
1566 ms |
208 KB |
Output is correct |
42 |
Correct |
1527 ms |
308 KB |
Output is correct |
43 |
Correct |
1436 ms |
208 KB |
Output is correct |
44 |
Correct |
1435 ms |
208 KB |
Output is correct |
45 |
Correct |
1616 ms |
208 KB |
Output is correct |
46 |
Correct |
1674 ms |
208 KB |
Output is correct |
47 |
Correct |
1701 ms |
208 KB |
Output is correct |
48 |
Correct |
1360 ms |
208 KB |
Output is correct |
49 |
Correct |
1487 ms |
208 KB |
Output is correct |
50 |
Correct |
1655 ms |
208 KB |
Output is correct |
51 |
Correct |
1298 ms |
208 KB |
Output is correct |
52 |
Correct |
1441 ms |
208 KB |
Output is correct |