# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795468 | SlavicG | Minerals (JOI19_minerals) | C++17 | 24 ms | 2080 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
mt19937 rng(69);
void Solve(int n) {
vector<int> p1, p2;
int ans = 0, prevans = -1;
vector<int> bulanea(2 * n);
iota(bulanea.begin(), bulanea.end(), 1);
shuffle(bulanea.begin(), bulanea.end(), rng);
for(int i: bulanea) {
ans = Query(i);
if(ans == prevans) {
p2.push_back(i);
} else {
p1.push_back(i);
}
prevans = ans;
}
assert(p1.size() == n && p2.size() == n);
vector<int> pr(n, 0);
int IN = 1;
for(int bit = 0; (1 << bit) < n; ++bit) {
for(int i = 0; i < n; ++i) {
if(i >> bit & 1) continue;
prevans = Query(p1[i]);
}
for(int i = 0; i < n; ++i) {
int ans = Query(p2[i]);
if(ans == prevans) {
pr[i] += (1 << bit);
}
prevans = ans;
}
IN ^= 1;
for(int i = 0; i < n; ++i) {
if(i >> bit & 1) continue;
prevans = Query(p1[i]);
}
}
for(int i = 0; i < n; ++i) {
Answer(p2[i], p1[pr[i]]);
}
}
/*
4
1 5
2 6
3 4
7 8
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |