#include "minerals.h"
#include <algorithm>
#include <vector>
using namespace std;
vector<int> firsts, ans;
int lquery = 0;
void recurse(vector<int> &v, int l, int r, bool has = true) {
if (l != r) {
int m = (l + r) / 2;
for (int i = l; i <= m; ++i) lquery = Query(i);
vector<int> a, b;
for (int i: v) {
int x = Query(i);
if (has == (x != lquery)) a.push_back(i);
else b.push_back(i);
if (x != lquery) lquery = x;
}
recurse(a, l, m, !has);
recurse(b, m + 1, r, has);
} else ans.push_back(v[0]);
}
void Solve(int N) {
vector<int> duds;
for (int i = 1; i <= 2 * N; ++i) {
int x = Query(i);
if (x != lquery) firsts.push_back(i), lquery = x;
else duds.push_back(i);
}
recurse(duds, 0, N - 1);
for (int i = 0; i < N; ++i) Answer(firsts[i], ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |