#include <iostream>
#include <vector>
#include <set>
#include "minerals.h"
using namespace std;
set<int> on;
int ans;
void solve(vector<int> a, vector<int> b) {
// for (int num : a) cout << num << ' ';
// cout << endl;
// for (int num : b) cout << num << ' ';
// cout << endl;
// cout << endl;
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size() / 2, m = a.size() - n;
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.count(i)) ans = Query(i), on.insert(i);
for (int i : a2) if (on.count(i)) ans = Query(i), on.erase(i);
for (int i : b) {
if (b1.size() == n) {
b2.push_back(i);
continue;
} else 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) {
// cout << "here" << endl;
vector<int> a, b;
int last = 0;
for (int i = 1; i <= 2 * n; ++i) {
int now = Query(i);
ans = now;
if (now > last) a.push_back(i), on.insert(i);
else b.push_back(i);
last = now;
}
for (int i : b) ans = Query(i);
solve(a, b);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
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 (b1.size() == n) {
| ~~~~~~~~~~^~~~
minerals.cpp:31:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
31 | } else if (b2.size() == m) {
| ~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
464 KB |
Output is correct |
3 |
Correct |
8 ms |
592 KB |
Output is correct |
4 |
Correct |
15 ms |
1012 KB |
Output is correct |
5 |
Correct |
35 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
19 |
Correct |
91 ms |
4508 KB |
Output is correct |
20 |
Correct |
103 ms |
4528 KB |
Output is correct |
21 |
Correct |
87 ms |
4580 KB |
Output is correct |
22 |
Correct |
81 ms |
4348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
19 |
Correct |
91 ms |
4508 KB |
Output is correct |
20 |
Correct |
103 ms |
4528 KB |
Output is correct |
21 |
Correct |
87 ms |
4580 KB |
Output is correct |
22 |
Correct |
81 ms |
4348 KB |
Output is correct |
23 |
Correct |
102 ms |
4708 KB |
Output is correct |
24 |
Correct |
95 ms |
4640 KB |
Output is correct |
25 |
Correct |
82 ms |
4696 KB |
Output is correct |
26 |
Correct |
84 ms |
4548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
19 |
Correct |
91 ms |
4508 KB |
Output is correct |
20 |
Correct |
103 ms |
4528 KB |
Output is correct |
21 |
Correct |
87 ms |
4580 KB |
Output is correct |
22 |
Correct |
81 ms |
4348 KB |
Output is correct |
23 |
Correct |
102 ms |
4708 KB |
Output is correct |
24 |
Correct |
95 ms |
4640 KB |
Output is correct |
25 |
Correct |
82 ms |
4696 KB |
Output is correct |
26 |
Correct |
84 ms |
4548 KB |
Output is correct |
27 |
Incorrect |
100 ms |
4744 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
19 |
Correct |
91 ms |
4508 KB |
Output is correct |
20 |
Correct |
103 ms |
4528 KB |
Output is correct |
21 |
Correct |
87 ms |
4580 KB |
Output is correct |
22 |
Correct |
81 ms |
4348 KB |
Output is correct |
23 |
Correct |
102 ms |
4708 KB |
Output is correct |
24 |
Correct |
95 ms |
4640 KB |
Output is correct |
25 |
Correct |
82 ms |
4696 KB |
Output is correct |
26 |
Correct |
84 ms |
4548 KB |
Output is correct |
27 |
Incorrect |
100 ms |
4744 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
8 ms |
592 KB |
Output is correct |
8 |
Correct |
15 ms |
1012 KB |
Output is correct |
9 |
Correct |
35 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
21 ms |
1312 KB |
Output is correct |
12 |
Correct |
32 ms |
1752 KB |
Output is correct |
13 |
Correct |
27 ms |
1864 KB |
Output is correct |
14 |
Correct |
32 ms |
1736 KB |
Output is correct |
15 |
Correct |
92 ms |
4516 KB |
Output is correct |
16 |
Correct |
87 ms |
4396 KB |
Output is correct |
17 |
Correct |
80 ms |
4472 KB |
Output is correct |
18 |
Correct |
81 ms |
4272 KB |
Output is correct |
19 |
Correct |
91 ms |
4508 KB |
Output is correct |
20 |
Correct |
103 ms |
4528 KB |
Output is correct |
21 |
Correct |
87 ms |
4580 KB |
Output is correct |
22 |
Correct |
81 ms |
4348 KB |
Output is correct |
23 |
Correct |
102 ms |
4708 KB |
Output is correct |
24 |
Correct |
95 ms |
4640 KB |
Output is correct |
25 |
Correct |
82 ms |
4696 KB |
Output is correct |
26 |
Correct |
84 ms |
4548 KB |
Output is correct |
27 |
Incorrect |
100 ms |
4744 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |