// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
template<class T> using V = vector<T>;
using vi = V<int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
auto ask = [&](int l, int r) {
if (l < 0 || r >= N) return 0;
cout << "? " << l + 1 << " " << r + 1 << endl;
int res; cin >> res; return res;
};
int odd = 0, even = 0;
for(int i = 0; i < N; i++) {
while(ask(i - odd - 1, i + odd + 1)) odd++;
while(ask(i - even, i + even + 1)) even++;
}
cout << "! " << max(2 * odd + 1, 2 * even) << endl;
exit(0-0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
63 ms |
596 KB |
Output is correct |
3 |
Correct |
58 ms |
344 KB |
Output is correct |
4 |
Correct |
61 ms |
344 KB |
Output is correct |
5 |
Correct |
72 ms |
344 KB |
Output is correct |
6 |
Correct |
64 ms |
344 KB |
Output is correct |
7 |
Correct |
59 ms |
344 KB |
Output is correct |
8 |
Correct |
58 ms |
344 KB |
Output is correct |
9 |
Correct |
69 ms |
344 KB |
Output is correct |
10 |
Correct |
61 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
63 ms |
596 KB |
Output is correct |
3 |
Correct |
58 ms |
344 KB |
Output is correct |
4 |
Correct |
61 ms |
344 KB |
Output is correct |
5 |
Correct |
72 ms |
344 KB |
Output is correct |
6 |
Correct |
64 ms |
344 KB |
Output is correct |
7 |
Correct |
59 ms |
344 KB |
Output is correct |
8 |
Correct |
58 ms |
344 KB |
Output is correct |
9 |
Correct |
69 ms |
344 KB |
Output is correct |
10 |
Correct |
61 ms |
344 KB |
Output is correct |
11 |
Correct |
573 ms |
516 KB |
Output is correct |
12 |
Correct |
562 ms |
344 KB |
Output is correct |
13 |
Correct |
595 ms |
344 KB |
Output is correct |
14 |
Correct |
550 ms |
344 KB |
Output is correct |
15 |
Correct |
550 ms |
344 KB |
Output is correct |
16 |
Correct |
568 ms |
596 KB |
Output is correct |
17 |
Correct |
541 ms |
344 KB |
Output is correct |
18 |
Correct |
536 ms |
604 KB |
Output is correct |
19 |
Correct |
601 ms |
344 KB |
Output is correct |
20 |
Correct |
534 ms |
344 KB |
Output is correct |
21 |
Correct |
574 ms |
344 KB |
Output is correct |
22 |
Correct |
572 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
908 ms |
344 KB |
Output is correct |
2 |
Correct |
639 ms |
344 KB |
Output is correct |
3 |
Correct |
856 ms |
344 KB |
Output is correct |
4 |
Correct |
853 ms |
344 KB |
Output is correct |
5 |
Correct |
897 ms |
344 KB |
Output is correct |
6 |
Correct |
850 ms |
344 KB |
Output is correct |
7 |
Correct |
877 ms |
344 KB |
Output is correct |
8 |
Correct |
858 ms |
344 KB |
Output is correct |
9 |
Correct |
844 ms |
344 KB |
Output is correct |
10 |
Correct |
871 ms |
344 KB |
Output is correct |
11 |
Correct |
880 ms |
516 KB |
Output is correct |
12 |
Correct |
893 ms |
344 KB |
Output is correct |
13 |
Correct |
921 ms |
344 KB |
Output is correct |
14 |
Correct |
909 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
344 KB |
Output is correct |
2 |
Correct |
63 ms |
596 KB |
Output is correct |
3 |
Correct |
58 ms |
344 KB |
Output is correct |
4 |
Correct |
61 ms |
344 KB |
Output is correct |
5 |
Correct |
72 ms |
344 KB |
Output is correct |
6 |
Correct |
64 ms |
344 KB |
Output is correct |
7 |
Correct |
59 ms |
344 KB |
Output is correct |
8 |
Correct |
58 ms |
344 KB |
Output is correct |
9 |
Correct |
69 ms |
344 KB |
Output is correct |
10 |
Correct |
61 ms |
344 KB |
Output is correct |
11 |
Correct |
573 ms |
516 KB |
Output is correct |
12 |
Correct |
562 ms |
344 KB |
Output is correct |
13 |
Correct |
595 ms |
344 KB |
Output is correct |
14 |
Correct |
550 ms |
344 KB |
Output is correct |
15 |
Correct |
550 ms |
344 KB |
Output is correct |
16 |
Correct |
568 ms |
596 KB |
Output is correct |
17 |
Correct |
541 ms |
344 KB |
Output is correct |
18 |
Correct |
536 ms |
604 KB |
Output is correct |
19 |
Correct |
601 ms |
344 KB |
Output is correct |
20 |
Correct |
534 ms |
344 KB |
Output is correct |
21 |
Correct |
574 ms |
344 KB |
Output is correct |
22 |
Correct |
572 ms |
344 KB |
Output is correct |
23 |
Correct |
908 ms |
344 KB |
Output is correct |
24 |
Correct |
639 ms |
344 KB |
Output is correct |
25 |
Correct |
856 ms |
344 KB |
Output is correct |
26 |
Correct |
853 ms |
344 KB |
Output is correct |
27 |
Correct |
897 ms |
344 KB |
Output is correct |
28 |
Correct |
850 ms |
344 KB |
Output is correct |
29 |
Correct |
877 ms |
344 KB |
Output is correct |
30 |
Correct |
858 ms |
344 KB |
Output is correct |
31 |
Correct |
844 ms |
344 KB |
Output is correct |
32 |
Correct |
871 ms |
344 KB |
Output is correct |
33 |
Correct |
880 ms |
516 KB |
Output is correct |
34 |
Correct |
893 ms |
344 KB |
Output is correct |
35 |
Correct |
921 ms |
344 KB |
Output is correct |
36 |
Correct |
909 ms |
344 KB |
Output is correct |
37 |
Correct |
855 ms |
344 KB |
Output is correct |
38 |
Correct |
897 ms |
344 KB |
Output is correct |
39 |
Correct |
895 ms |
344 KB |
Output is correct |
40 |
Correct |
902 ms |
344 KB |
Output is correct |
41 |
Correct |
865 ms |
344 KB |
Output is correct |
42 |
Correct |
875 ms |
344 KB |
Output is correct |
43 |
Correct |
868 ms |
344 KB |
Output is correct |
44 |
Correct |
879 ms |
344 KB |
Output is correct |
45 |
Correct |
898 ms |
344 KB |
Output is correct |
46 |
Correct |
920 ms |
344 KB |
Output is correct |
47 |
Correct |
907 ms |
344 KB |
Output is correct |
48 |
Correct |
930 ms |
344 KB |
Output is correct |
49 |
Correct |
853 ms |
344 KB |
Output is correct |
50 |
Correct |
875 ms |
344 KB |
Output is correct |
51 |
Correct |
857 ms |
344 KB |
Output is correct |
52 |
Correct |
905 ms |
344 KB |
Output is correct |