#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;
if(l < m-1 && m - l + 2 == 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 |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
4 |
Correct |
10 ms |
840 KB |
Output is correct |
5 |
Correct |
14 ms |
1224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
19 |
Correct |
48 ms |
3148 KB |
Output is correct |
20 |
Correct |
57 ms |
3144 KB |
Output is correct |
21 |
Correct |
40 ms |
3064 KB |
Output is correct |
22 |
Correct |
41 ms |
3004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
19 |
Correct |
48 ms |
3148 KB |
Output is correct |
20 |
Correct |
57 ms |
3144 KB |
Output is correct |
21 |
Correct |
40 ms |
3064 KB |
Output is correct |
22 |
Correct |
41 ms |
3004 KB |
Output is correct |
23 |
Correct |
52 ms |
3204 KB |
Output is correct |
24 |
Correct |
45 ms |
3232 KB |
Output is correct |
25 |
Correct |
37 ms |
3180 KB |
Output is correct |
26 |
Correct |
42 ms |
2996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
19 |
Correct |
48 ms |
3148 KB |
Output is correct |
20 |
Correct |
57 ms |
3144 KB |
Output is correct |
21 |
Correct |
40 ms |
3064 KB |
Output is correct |
22 |
Correct |
41 ms |
3004 KB |
Output is correct |
23 |
Correct |
52 ms |
3204 KB |
Output is correct |
24 |
Correct |
45 ms |
3232 KB |
Output is correct |
25 |
Correct |
37 ms |
3180 KB |
Output is correct |
26 |
Correct |
42 ms |
2996 KB |
Output is correct |
27 |
Correct |
49 ms |
3288 KB |
Output is correct |
28 |
Correct |
47 ms |
3276 KB |
Output is correct |
29 |
Correct |
44 ms |
3160 KB |
Output is correct |
30 |
Correct |
44 ms |
3120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
19 |
Correct |
48 ms |
3148 KB |
Output is correct |
20 |
Correct |
57 ms |
3144 KB |
Output is correct |
21 |
Correct |
40 ms |
3064 KB |
Output is correct |
22 |
Correct |
41 ms |
3004 KB |
Output is correct |
23 |
Correct |
52 ms |
3204 KB |
Output is correct |
24 |
Correct |
45 ms |
3232 KB |
Output is correct |
25 |
Correct |
37 ms |
3180 KB |
Output is correct |
26 |
Correct |
42 ms |
2996 KB |
Output is correct |
27 |
Correct |
49 ms |
3288 KB |
Output is correct |
28 |
Correct |
47 ms |
3276 KB |
Output is correct |
29 |
Correct |
44 ms |
3160 KB |
Output is correct |
30 |
Correct |
44 ms |
3120 KB |
Output is correct |
31 |
Correct |
46 ms |
3304 KB |
Output is correct |
32 |
Correct |
52 ms |
3380 KB |
Output is correct |
33 |
Correct |
45 ms |
3320 KB |
Output is correct |
34 |
Correct |
45 ms |
3272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 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 |
584 KB |
Output is correct |
8 |
Correct |
10 ms |
840 KB |
Output is correct |
9 |
Correct |
14 ms |
1224 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
968 KB |
Output is correct |
12 |
Correct |
15 ms |
1380 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
15 ms |
1280 KB |
Output is correct |
15 |
Correct |
46 ms |
3080 KB |
Output is correct |
16 |
Correct |
46 ms |
3088 KB |
Output is correct |
17 |
Correct |
37 ms |
2940 KB |
Output is correct |
18 |
Correct |
40 ms |
2908 KB |
Output is correct |
19 |
Correct |
48 ms |
3148 KB |
Output is correct |
20 |
Correct |
57 ms |
3144 KB |
Output is correct |
21 |
Correct |
40 ms |
3064 KB |
Output is correct |
22 |
Correct |
41 ms |
3004 KB |
Output is correct |
23 |
Correct |
52 ms |
3204 KB |
Output is correct |
24 |
Correct |
45 ms |
3232 KB |
Output is correct |
25 |
Correct |
37 ms |
3180 KB |
Output is correct |
26 |
Correct |
42 ms |
2996 KB |
Output is correct |
27 |
Correct |
49 ms |
3288 KB |
Output is correct |
28 |
Correct |
47 ms |
3276 KB |
Output is correct |
29 |
Correct |
44 ms |
3160 KB |
Output is correct |
30 |
Correct |
44 ms |
3120 KB |
Output is correct |
31 |
Correct |
46 ms |
3304 KB |
Output is correct |
32 |
Correct |
52 ms |
3380 KB |
Output is correct |
33 |
Correct |
45 ms |
3320 KB |
Output is correct |
34 |
Correct |
45 ms |
3272 KB |
Output is correct |
35 |
Incorrect |
47 ms |
3328 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |