#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) {
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) {
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:23:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
23 | if (b1.size() == n) {
| ~~~~~~~~~~^~~~
minerals.cpp:26:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
26 | } else if (b2.size() == m) {
| ~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |