# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
502673 |
2022-01-06T12:25:40 Z |
sidon |
Minerals (JOI19_minerals) |
C++17 |
|
58 ms |
3288 KB |
#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(r - m > m - l) ++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);
}
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
328 KB |
Output is correct |
2 |
Correct |
3 ms |
328 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
7 ms |
732 KB |
Output is correct |
5 |
Correct |
13 ms |
1224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
19 |
Correct |
58 ms |
3140 KB |
Output is correct |
20 |
Correct |
53 ms |
3144 KB |
Output is correct |
21 |
Correct |
36 ms |
3004 KB |
Output is correct |
22 |
Correct |
41 ms |
2876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
19 |
Correct |
58 ms |
3140 KB |
Output is correct |
20 |
Correct |
53 ms |
3144 KB |
Output is correct |
21 |
Correct |
36 ms |
3004 KB |
Output is correct |
22 |
Correct |
41 ms |
2876 KB |
Output is correct |
23 |
Correct |
43 ms |
3192 KB |
Output is correct |
24 |
Correct |
42 ms |
3156 KB |
Output is correct |
25 |
Correct |
38 ms |
3132 KB |
Output is correct |
26 |
Correct |
51 ms |
3044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
19 |
Correct |
58 ms |
3140 KB |
Output is correct |
20 |
Correct |
53 ms |
3144 KB |
Output is correct |
21 |
Correct |
36 ms |
3004 KB |
Output is correct |
22 |
Correct |
41 ms |
2876 KB |
Output is correct |
23 |
Correct |
43 ms |
3192 KB |
Output is correct |
24 |
Correct |
42 ms |
3156 KB |
Output is correct |
25 |
Correct |
38 ms |
3132 KB |
Output is correct |
26 |
Correct |
51 ms |
3044 KB |
Output is correct |
27 |
Correct |
43 ms |
3204 KB |
Output is correct |
28 |
Correct |
46 ms |
3260 KB |
Output is correct |
29 |
Correct |
39 ms |
3148 KB |
Output is correct |
30 |
Correct |
58 ms |
3132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
19 |
Correct |
58 ms |
3140 KB |
Output is correct |
20 |
Correct |
53 ms |
3144 KB |
Output is correct |
21 |
Correct |
36 ms |
3004 KB |
Output is correct |
22 |
Correct |
41 ms |
2876 KB |
Output is correct |
23 |
Correct |
43 ms |
3192 KB |
Output is correct |
24 |
Correct |
42 ms |
3156 KB |
Output is correct |
25 |
Correct |
38 ms |
3132 KB |
Output is correct |
26 |
Correct |
51 ms |
3044 KB |
Output is correct |
27 |
Correct |
43 ms |
3204 KB |
Output is correct |
28 |
Correct |
46 ms |
3260 KB |
Output is correct |
29 |
Correct |
39 ms |
3148 KB |
Output is correct |
30 |
Correct |
58 ms |
3132 KB |
Output is correct |
31 |
Incorrect |
48 ms |
3288 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
7 ms |
732 KB |
Output is correct |
9 |
Correct |
13 ms |
1224 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
14 ms |
1280 KB |
Output is correct |
13 |
Correct |
15 ms |
1380 KB |
Output is correct |
14 |
Correct |
20 ms |
1320 KB |
Output is correct |
15 |
Correct |
50 ms |
3012 KB |
Output is correct |
16 |
Correct |
50 ms |
3056 KB |
Output is correct |
17 |
Correct |
35 ms |
2960 KB |
Output is correct |
18 |
Correct |
46 ms |
2956 KB |
Output is correct |
19 |
Correct |
58 ms |
3140 KB |
Output is correct |
20 |
Correct |
53 ms |
3144 KB |
Output is correct |
21 |
Correct |
36 ms |
3004 KB |
Output is correct |
22 |
Correct |
41 ms |
2876 KB |
Output is correct |
23 |
Correct |
43 ms |
3192 KB |
Output is correct |
24 |
Correct |
42 ms |
3156 KB |
Output is correct |
25 |
Correct |
38 ms |
3132 KB |
Output is correct |
26 |
Correct |
51 ms |
3044 KB |
Output is correct |
27 |
Correct |
43 ms |
3204 KB |
Output is correct |
28 |
Correct |
46 ms |
3260 KB |
Output is correct |
29 |
Correct |
39 ms |
3148 KB |
Output is correct |
30 |
Correct |
58 ms |
3132 KB |
Output is correct |
31 |
Incorrect |
48 ms |
3288 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |