# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
250090 | dantoh000 | Minerals (JOI19_minerals) | C++14 | 32 ms | 2420 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;
vector<int> Q;
vector<int> P;
int ans[86005];
void solve(vector<int> p, int l, int r){
if (r == l){
//printf("%d -> %d\n",Q[l],p[0]);
ans[Q[l]] = p[0];
return;
}
/*printf("new\n");
for (auto x : p){
printf("%d ",x);
}
printf("<- P\n");
for (int i = l; i <= r; i++){
printf("%d ",Q[i]);
}
printf("<- Q\n");*/
assert(p.size() == r-l+1);
vector<int> Lp;
vector<int> Rp;
int n = r-l+1;
int mid = (l+r)/2;
int last;
for (int i = mid+1; i <= r; i++){
//printf("solve: removing %d\n",Q[i]);
last = Query(Q[i]);
}
for (int i = 0; i < n; i++){
//printf("solve: removing %d\n",p[i]);
int q = Query(p[i]);
if (q == last){
//printf("solve: adding %d\n",p[i]);
Query(p[i]);
Lp.push_back(p[i]);
}
else{
Rp.push_back(p[i]);
}
last = q;
}
solve(Lp, l, mid);
for (auto x : p) {
//printf("solve: removing/adding %d\n",x);
Query(x);
}
for (int i = l; i <= r; i++) {
//printf("solve: removing/adding %d\n",Q[i]);
Query(Q[i]);
}
solve(Rp, mid+1, r);
}
void Solve(int N) {
int last = 0;
for (int i = 1; i <= 2*N; i++){
int q = Query(i);
if (q == last){
Q.push_back(i);
}
else{
P.push_back(i);
}
last = q;
}
solve(P,0,N-1);
for (auto x: Q){
Answer(x,ans[x]);
}
}
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... |