#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
const int LIM = 43e3;
int A[LIM], L, R = -1, last;
#define ask(Z) (last = Query(Z))
void dfs(int l, int r, vector<int> b, bool on) {
if(r - l < 1) return;
if(r - l < 2) return Answer(A[l], b[0]);
int m = (l + r) / 2;
if(l < m-1 && m - l == r - m) --m;
if(l < m-1 && m - l + 1 == r - m) --m;
for(int i = l; i < m; ++i)
ask(A[i]);
vector<int> bL, bR;
for(int &i : b) {
if((int)size(bL) == m - l) {
bR.push_back(i);
continue;
}
if((int)size(bR) == r - m) {
bL.push_back(i);
continue;
}
int prev = last;
((prev == ask(i)) ^ on ? bL : bR).push_back(i);
}
dfs(l, m, bL, on ^ 1);
dfs(m, r, bR, on);
}
void Solve(int N) {
array<int, 2> s[N+N];
for(unsigned int i = 0, j = 12345; int(i) < N + N; ++i)
s[i] = {int((j *= 3) >> 1), int(i)+1};
sort(s, s+N+N);
vector<int> b;
for(auto &[_, i] : s) {
if(R == N - 1 || ask(i) < R + 2) {
b.push_back(i);
} else A[++R] = i;
}
dfs(0, N, b, 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Correct |
4 ms |
456 KB |
Output is correct |
4 |
Correct |
7 ms |
844 KB |
Output is correct |
5 |
Correct |
17 ms |
1308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
19 |
Correct |
43 ms |
3148 KB |
Output is correct |
20 |
Correct |
43 ms |
3132 KB |
Output is correct |
21 |
Correct |
36 ms |
3104 KB |
Output is correct |
22 |
Correct |
40 ms |
3004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
19 |
Correct |
43 ms |
3148 KB |
Output is correct |
20 |
Correct |
43 ms |
3132 KB |
Output is correct |
21 |
Correct |
36 ms |
3104 KB |
Output is correct |
22 |
Correct |
40 ms |
3004 KB |
Output is correct |
23 |
Correct |
42 ms |
3228 KB |
Output is correct |
24 |
Correct |
42 ms |
3148 KB |
Output is correct |
25 |
Correct |
39 ms |
3136 KB |
Output is correct |
26 |
Correct |
46 ms |
3204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
19 |
Correct |
43 ms |
3148 KB |
Output is correct |
20 |
Correct |
43 ms |
3132 KB |
Output is correct |
21 |
Correct |
36 ms |
3104 KB |
Output is correct |
22 |
Correct |
40 ms |
3004 KB |
Output is correct |
23 |
Correct |
42 ms |
3228 KB |
Output is correct |
24 |
Correct |
42 ms |
3148 KB |
Output is correct |
25 |
Correct |
39 ms |
3136 KB |
Output is correct |
26 |
Correct |
46 ms |
3204 KB |
Output is correct |
27 |
Correct |
50 ms |
3292 KB |
Output is correct |
28 |
Correct |
50 ms |
3300 KB |
Output is correct |
29 |
Correct |
38 ms |
3148 KB |
Output is correct |
30 |
Correct |
44 ms |
3148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
19 |
Correct |
43 ms |
3148 KB |
Output is correct |
20 |
Correct |
43 ms |
3132 KB |
Output is correct |
21 |
Correct |
36 ms |
3104 KB |
Output is correct |
22 |
Correct |
40 ms |
3004 KB |
Output is correct |
23 |
Correct |
42 ms |
3228 KB |
Output is correct |
24 |
Correct |
42 ms |
3148 KB |
Output is correct |
25 |
Correct |
39 ms |
3136 KB |
Output is correct |
26 |
Correct |
46 ms |
3204 KB |
Output is correct |
27 |
Correct |
50 ms |
3292 KB |
Output is correct |
28 |
Correct |
50 ms |
3300 KB |
Output is correct |
29 |
Correct |
38 ms |
3148 KB |
Output is correct |
30 |
Correct |
44 ms |
3148 KB |
Output is correct |
31 |
Correct |
46 ms |
3360 KB |
Output is correct |
32 |
Correct |
50 ms |
3284 KB |
Output is correct |
33 |
Correct |
40 ms |
3300 KB |
Output is correct |
34 |
Correct |
47 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
844 KB |
Output is correct |
9 |
Correct |
17 ms |
1308 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
13 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1312 KB |
Output is correct |
13 |
Correct |
16 ms |
1272 KB |
Output is correct |
14 |
Correct |
16 ms |
1328 KB |
Output is correct |
15 |
Correct |
45 ms |
3072 KB |
Output is correct |
16 |
Correct |
41 ms |
3012 KB |
Output is correct |
17 |
Correct |
36 ms |
3052 KB |
Output is correct |
18 |
Correct |
40 ms |
2860 KB |
Output is correct |
19 |
Correct |
43 ms |
3148 KB |
Output is correct |
20 |
Correct |
43 ms |
3132 KB |
Output is correct |
21 |
Correct |
36 ms |
3104 KB |
Output is correct |
22 |
Correct |
40 ms |
3004 KB |
Output is correct |
23 |
Correct |
42 ms |
3228 KB |
Output is correct |
24 |
Correct |
42 ms |
3148 KB |
Output is correct |
25 |
Correct |
39 ms |
3136 KB |
Output is correct |
26 |
Correct |
46 ms |
3204 KB |
Output is correct |
27 |
Correct |
50 ms |
3292 KB |
Output is correct |
28 |
Correct |
50 ms |
3300 KB |
Output is correct |
29 |
Correct |
38 ms |
3148 KB |
Output is correct |
30 |
Correct |
44 ms |
3148 KB |
Output is correct |
31 |
Correct |
46 ms |
3360 KB |
Output is correct |
32 |
Correct |
50 ms |
3284 KB |
Output is correct |
33 |
Correct |
40 ms |
3300 KB |
Output is correct |
34 |
Correct |
47 ms |
3156 KB |
Output is correct |
35 |
Incorrect |
47 ms |
3412 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |