# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
836142 | unnick | Minerals (JOI19_minerals) | C++14 | 13 ms | 1744 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"
#include <vector>
using namespace std;
void Solve(int N) {
vector<int> fst;
vector<int> snd;
int prev = 0;
for (int i = 1; i <= N*2; i++) {
int tmp = Query(i);
if (tmp > prev) fst.push_back(i);
prev = tmp;
}
for (int i = 1; i <= N*2; i++) {
int tmp = Query(i);
if (tmp < prev) snd.push_back(i);
prev = tmp;
}
int baseline;
for (int i = 0; i < N; i++) {
if (i&1) baseline = Query(fst[i]);
}
vector<int> ids(N, 0);
for (int pd = 1; pd < N; pd <<= 1) {
if (pd > 1) {
for (int i = 0; i < N; i++) {
if ((i&pd) ^ ((i<<1)&pd)) baseline = Query(fst[i]);
}
}
for (int i = 0; i < N; i++) {
int bit = !(Query(snd[i]) - baseline);
ids[i] += bit * pd;
Query(snd[i]);
}
}
for (int i = 0; i < N; i++) {
Answer(fst[ids[i]], snd[i]);
}
}
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... |