# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674274 | rainboy | Minerals (JOI19_minerals) | C++17 | 31 ms | 2540 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 "minerals.h"
const int N = 43000, L = 16;
int k;
int Query_(int i) {
int k_ = Query(i + 1);
if (k_ == k)
return 0;
k = k_;
return 1;
}
int tt[N * 2], ii[2][N], ii_[1 << L], nn[2], aa[N], bb[N];
void Solve(int n) {
k = 0;
for (int i = 0; i < n * 2; i++) {
tt[i] = !Query_(i);
ii[tt[i]][nn[tt[i]]++] = i;
}
for (int i = 0; i < n; i++) {
int a = 0, c = 1;
for (int l = 0; l < L; l++) {
if ((i & 1 << l) != 0)
c ^= 1;
if (c)
a |= 1 << l;
}
aa[i] = a;
}
for (int l = 0; l < L; l++) {
for (int i = 0; i < n; i++)
if ((aa[i] >> l & 1) != (l == 0 ? 1 : (aa[i] >> l - 1 & 1)))
Query_(ii[0][i]);
for (int i = 0; i < n; i++)
if (!Query_(ii[1][i]))
bb[i] |= 1 << l;
}
for (int i = 0; i < n; i++)
ii_[aa[i]] = ii[0][i];
for (int i = 0; i < n; i++)
Answer(ii_[bb[i]] + 1, ii[1][i] + 1);
}
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... |