#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()
using i64 = long long;
void main_() {
int N;
cin >> N;
vector<pair<int, int>> s;
rep(i, 0, N) s.push_back({i, i});
rep(i, 0, N - 1) s.push_back({i, i + 1});
sort(ALL(s), [&](const auto a, const auto b) {
int x = 2 * min(a.first, N - a.second - 1);
if (a.first != a.second) ++x;
int y = 2 * min(b.first, N - b.second - 1);
if (b.first != b.second) ++y;
return x < y;
});
reverse(ALL(s));
int ans = 1;
for (const auto &[a, b] : s) {
int x = 2 * min(a, N - b - 1) + 2;
if (a == b) --x;
if (x < ans + 1) continue;
while (true) {
if (x < ans + 1) break;
int p = ans + 1;
if (x % 2 != p % 2) ++p;
if (p > x) break;
cout << '?';
int u = (p - 1) / 2;
cout << ' ' << a - u + 1 << ' ' << b + u + 1 << endl;
int res;
cin >> res;
if (res == 1) ans = p;
else break;
}
}
cout << '!' << ' ' << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
main_();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
680 KB |
Output is correct |
2 |
Correct |
82 ms |
672 KB |
Output is correct |
3 |
Correct |
79 ms |
672 KB |
Output is correct |
4 |
Correct |
86 ms |
676 KB |
Output is correct |
5 |
Correct |
56 ms |
676 KB |
Output is correct |
6 |
Correct |
72 ms |
676 KB |
Output is correct |
7 |
Correct |
16 ms |
848 KB |
Output is correct |
8 |
Correct |
16 ms |
848 KB |
Output is correct |
9 |
Correct |
57 ms |
680 KB |
Output is correct |
10 |
Correct |
69 ms |
676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
680 KB |
Output is correct |
2 |
Correct |
82 ms |
672 KB |
Output is correct |
3 |
Correct |
79 ms |
672 KB |
Output is correct |
4 |
Correct |
86 ms |
676 KB |
Output is correct |
5 |
Correct |
56 ms |
676 KB |
Output is correct |
6 |
Correct |
72 ms |
676 KB |
Output is correct |
7 |
Correct |
16 ms |
848 KB |
Output is correct |
8 |
Correct |
16 ms |
848 KB |
Output is correct |
9 |
Correct |
57 ms |
680 KB |
Output is correct |
10 |
Correct |
69 ms |
676 KB |
Output is correct |
11 |
Correct |
685 ms |
1496 KB |
Output is correct |
12 |
Correct |
705 ms |
1496 KB |
Output is correct |
13 |
Correct |
646 ms |
1496 KB |
Output is correct |
14 |
Correct |
610 ms |
1496 KB |
Output is correct |
15 |
Correct |
618 ms |
1496 KB |
Output is correct |
16 |
Correct |
173 ms |
1496 KB |
Output is correct |
17 |
Correct |
194 ms |
1496 KB |
Output is correct |
18 |
Correct |
689 ms |
1496 KB |
Output is correct |
19 |
Correct |
174 ms |
1496 KB |
Output is correct |
20 |
Correct |
678 ms |
1748 KB |
Output is correct |
21 |
Correct |
655 ms |
1496 KB |
Output is correct |
22 |
Correct |
711 ms |
1496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1012 ms |
2516 KB |
Output is correct |
2 |
Correct |
281 ms |
2516 KB |
Output is correct |
3 |
Correct |
983 ms |
2516 KB |
Output is correct |
4 |
Correct |
560 ms |
2516 KB |
Output is correct |
5 |
Correct |
289 ms |
2516 KB |
Output is correct |
6 |
Correct |
1026 ms |
2516 KB |
Output is correct |
7 |
Correct |
275 ms |
2516 KB |
Output is correct |
8 |
Correct |
1031 ms |
2516 KB |
Output is correct |
9 |
Correct |
1080 ms |
2516 KB |
Output is correct |
10 |
Correct |
1088 ms |
2516 KB |
Output is correct |
11 |
Correct |
296 ms |
2516 KB |
Output is correct |
12 |
Correct |
286 ms |
2516 KB |
Output is correct |
13 |
Correct |
1033 ms |
2516 KB |
Output is correct |
14 |
Correct |
1090 ms |
2516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
680 KB |
Output is correct |
2 |
Correct |
82 ms |
672 KB |
Output is correct |
3 |
Correct |
79 ms |
672 KB |
Output is correct |
4 |
Correct |
86 ms |
676 KB |
Output is correct |
5 |
Correct |
56 ms |
676 KB |
Output is correct |
6 |
Correct |
72 ms |
676 KB |
Output is correct |
7 |
Correct |
16 ms |
848 KB |
Output is correct |
8 |
Correct |
16 ms |
848 KB |
Output is correct |
9 |
Correct |
57 ms |
680 KB |
Output is correct |
10 |
Correct |
69 ms |
676 KB |
Output is correct |
11 |
Correct |
685 ms |
1496 KB |
Output is correct |
12 |
Correct |
705 ms |
1496 KB |
Output is correct |
13 |
Correct |
646 ms |
1496 KB |
Output is correct |
14 |
Correct |
610 ms |
1496 KB |
Output is correct |
15 |
Correct |
618 ms |
1496 KB |
Output is correct |
16 |
Correct |
173 ms |
1496 KB |
Output is correct |
17 |
Correct |
194 ms |
1496 KB |
Output is correct |
18 |
Correct |
689 ms |
1496 KB |
Output is correct |
19 |
Correct |
174 ms |
1496 KB |
Output is correct |
20 |
Correct |
678 ms |
1748 KB |
Output is correct |
21 |
Correct |
655 ms |
1496 KB |
Output is correct |
22 |
Correct |
711 ms |
1496 KB |
Output is correct |
23 |
Correct |
1012 ms |
2516 KB |
Output is correct |
24 |
Correct |
281 ms |
2516 KB |
Output is correct |
25 |
Correct |
983 ms |
2516 KB |
Output is correct |
26 |
Correct |
560 ms |
2516 KB |
Output is correct |
27 |
Correct |
289 ms |
2516 KB |
Output is correct |
28 |
Correct |
1026 ms |
2516 KB |
Output is correct |
29 |
Correct |
275 ms |
2516 KB |
Output is correct |
30 |
Correct |
1031 ms |
2516 KB |
Output is correct |
31 |
Correct |
1080 ms |
2516 KB |
Output is correct |
32 |
Correct |
1088 ms |
2516 KB |
Output is correct |
33 |
Correct |
296 ms |
2516 KB |
Output is correct |
34 |
Correct |
286 ms |
2516 KB |
Output is correct |
35 |
Correct |
1033 ms |
2516 KB |
Output is correct |
36 |
Correct |
1090 ms |
2516 KB |
Output is correct |
37 |
Correct |
1093 ms |
2516 KB |
Output is correct |
38 |
Correct |
1041 ms |
2516 KB |
Output is correct |
39 |
Correct |
1067 ms |
2516 KB |
Output is correct |
40 |
Correct |
1027 ms |
2516 KB |
Output is correct |
41 |
Correct |
1012 ms |
2516 KB |
Output is correct |
42 |
Correct |
566 ms |
2516 KB |
Output is correct |
43 |
Correct |
270 ms |
2516 KB |
Output is correct |
44 |
Correct |
1000 ms |
2516 KB |
Output is correct |
45 |
Correct |
262 ms |
2516 KB |
Output is correct |
46 |
Correct |
1081 ms |
2516 KB |
Output is correct |
47 |
Correct |
1104 ms |
2516 KB |
Output is correct |
48 |
Correct |
1132 ms |
2516 KB |
Output is correct |
49 |
Correct |
244 ms |
2516 KB |
Output is correct |
50 |
Correct |
290 ms |
2516 KB |
Output is correct |
51 |
Correct |
1063 ms |
2512 KB |
Output is correct |
52 |
Correct |
1049 ms |
2516 KB |
Output is correct |