#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
vector<bool> on;
int ans;
void solve(vector<int> a, vector<int> b) {
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size() / 2, m = a.size() - n;
for (int i = 4; i <= a.size(); i *= 2) --n, ++m;
for (int i = 25; i <= a.size(); i *= 2) --n, ++m;
if (on[a[0]]) swap(n, m);
vector<int> a1(n), a2(m);
vector<int> b1, b2;
for (int i = 0; i < n; ++i) a1[i] = a[i];
for (int i = 0; i < m; ++i) a2[i] = a[i + n];
for (int i : a1) if (!on[i]) ans = Query(i), on[i] = 1;
for (int i : a2) if (on[i]) ans = Query(i), on[i] = 0;
for (int i : b) {
if (b1.size() == n) {
b2.push_back(i);
continue;
}
if (b2.size() == m) {
b1.push_back(i);
continue;
}
int now = Query(i);
if (now == ans) b1.push_back(i);
else b2.push_back(i);
ans = now;
}
solve(a1, b1), solve(a2, b2);
}
void Solve(int n) {
on.resize(2 * n + 1);
vector<int> a, b;
int last = 0;
for (int i = 1; i <= 2 * n; ++i) {
if (a.size() == n) {
b.push_back(i);
continue;
}
if (b.size() == n) {
a.push_back(i);
continue;
}
int now = Query(i);
if (now > last) a.push_back(i), on[i] = 1;
else b.push_back(i);
last = ans = now;
}
solve(a, b);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 4; i <= a.size(); i *= 2) --n, ++m;
| ~~^~~~~~~~~~~
minerals.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for (int i = 25; i <= a.size(); i *= 2) --n, ++m;
| ~~^~~~~~~~~~~
minerals.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | if (b1.size() == n) {
| ~~~~~~~~~~^~~~
minerals.cpp:28:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | if (b2.size() == m) {
| ~~~~~~~~~~^~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | if (a.size() == n) {
| ~~~~~~~~~^~~~
minerals.cpp:49:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
49 | if (b.size() == n) {
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
404 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
7 ms |
904 KB |
Output is correct |
5 |
Correct |
15 ms |
1488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
19 |
Correct |
39 ms |
3476 KB |
Output is correct |
20 |
Correct |
41 ms |
3372 KB |
Output is correct |
21 |
Correct |
29 ms |
3416 KB |
Output is correct |
22 |
Correct |
29 ms |
3216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
19 |
Correct |
39 ms |
3476 KB |
Output is correct |
20 |
Correct |
41 ms |
3372 KB |
Output is correct |
21 |
Correct |
29 ms |
3416 KB |
Output is correct |
22 |
Correct |
29 ms |
3216 KB |
Output is correct |
23 |
Correct |
40 ms |
3572 KB |
Output is correct |
24 |
Correct |
37 ms |
3516 KB |
Output is correct |
25 |
Correct |
29 ms |
3540 KB |
Output is correct |
26 |
Correct |
32 ms |
3292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
19 |
Correct |
39 ms |
3476 KB |
Output is correct |
20 |
Correct |
41 ms |
3372 KB |
Output is correct |
21 |
Correct |
29 ms |
3416 KB |
Output is correct |
22 |
Correct |
29 ms |
3216 KB |
Output is correct |
23 |
Correct |
40 ms |
3572 KB |
Output is correct |
24 |
Correct |
37 ms |
3516 KB |
Output is correct |
25 |
Correct |
29 ms |
3540 KB |
Output is correct |
26 |
Correct |
32 ms |
3292 KB |
Output is correct |
27 |
Correct |
46 ms |
3600 KB |
Output is correct |
28 |
Correct |
39 ms |
3684 KB |
Output is correct |
29 |
Correct |
30 ms |
3552 KB |
Output is correct |
30 |
Correct |
32 ms |
3452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
19 |
Correct |
39 ms |
3476 KB |
Output is correct |
20 |
Correct |
41 ms |
3372 KB |
Output is correct |
21 |
Correct |
29 ms |
3416 KB |
Output is correct |
22 |
Correct |
29 ms |
3216 KB |
Output is correct |
23 |
Correct |
40 ms |
3572 KB |
Output is correct |
24 |
Correct |
37 ms |
3516 KB |
Output is correct |
25 |
Correct |
29 ms |
3540 KB |
Output is correct |
26 |
Correct |
32 ms |
3292 KB |
Output is correct |
27 |
Correct |
46 ms |
3600 KB |
Output is correct |
28 |
Correct |
39 ms |
3684 KB |
Output is correct |
29 |
Correct |
30 ms |
3552 KB |
Output is correct |
30 |
Correct |
32 ms |
3452 KB |
Output is correct |
31 |
Correct |
42 ms |
3768 KB |
Output is correct |
32 |
Correct |
39 ms |
3728 KB |
Output is correct |
33 |
Correct |
31 ms |
3684 KB |
Output is correct |
34 |
Correct |
31 ms |
3528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
404 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
7 ms |
904 KB |
Output is correct |
9 |
Correct |
15 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
1140 KB |
Output is correct |
12 |
Correct |
14 ms |
1488 KB |
Output is correct |
13 |
Correct |
12 ms |
1556 KB |
Output is correct |
14 |
Correct |
11 ms |
1436 KB |
Output is correct |
15 |
Correct |
38 ms |
3392 KB |
Output is correct |
16 |
Correct |
36 ms |
3380 KB |
Output is correct |
17 |
Correct |
28 ms |
3316 KB |
Output is correct |
18 |
Correct |
28 ms |
3164 KB |
Output is correct |
19 |
Correct |
39 ms |
3476 KB |
Output is correct |
20 |
Correct |
41 ms |
3372 KB |
Output is correct |
21 |
Correct |
29 ms |
3416 KB |
Output is correct |
22 |
Correct |
29 ms |
3216 KB |
Output is correct |
23 |
Correct |
40 ms |
3572 KB |
Output is correct |
24 |
Correct |
37 ms |
3516 KB |
Output is correct |
25 |
Correct |
29 ms |
3540 KB |
Output is correct |
26 |
Correct |
32 ms |
3292 KB |
Output is correct |
27 |
Correct |
46 ms |
3600 KB |
Output is correct |
28 |
Correct |
39 ms |
3684 KB |
Output is correct |
29 |
Correct |
30 ms |
3552 KB |
Output is correct |
30 |
Correct |
32 ms |
3452 KB |
Output is correct |
31 |
Correct |
42 ms |
3768 KB |
Output is correct |
32 |
Correct |
39 ms |
3728 KB |
Output is correct |
33 |
Correct |
31 ms |
3684 KB |
Output is correct |
34 |
Correct |
31 ms |
3528 KB |
Output is correct |
35 |
Correct |
41 ms |
3768 KB |
Output is correct |
36 |
Correct |
41 ms |
3736 KB |
Output is correct |
37 |
Correct |
31 ms |
3744 KB |
Output is correct |
38 |
Correct |
42 ms |
3484 KB |
Output is correct |