# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502643 | sidon | Minerals (JOI19_minerals) | C++17 | 29 ms | 2424 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 <bits/stdc++.h>
using namespace std;
const int LIM = 43e3;
int A[LIM], L, R = -1;
void extend(int lv, int rv) {
while(lv < L) Query(A[--L]);
while(rv > R) Query(A[++R]);
while(lv > L) Query(A[L++]);
while(rv < R) Query(A[R--]);
}
void dfs(int l, int r, vector<int> b) {
assert(size(b) == r-l);
if(l == r) return;
if(l == r - 1) return Answer(A[l], b[0]);
int m = (l + r) / 2;
extend(l, m-1);
vector<int> bL, bR;
for(int &i : b) {
if((int)size(bL) == m - l) bR.push_back(i);
else if((int)size(bR) == r - m) bL.push_back(i);
else
(Query(i) == Query(i) ? bL : bR).push_back(i);
}
dfs(l, m, bL);
dfs(m, r, bR);
}
void Solve(int N) {
vector<int> b;
for(int i = 1; i <= N * 2; ++i) {
if(R == N - 1 || Query(i) < R + 2) {
b.push_back(i);
Query(i);
} else A[++R] = i;
}
dfs(0, N, b);
}
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... |