# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710721 | victor_gao | Minerals (JOI19_minerals) | C++17 | 59 ms | 3064 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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int>arr;
bool alive[100015],vis[100015];
int n;
void Merge(int l,int r,vector<int>have,bool stay1){
//cerr<<l<<" "<<r<<" "<<stay1<<'\n';
if (l==r){
Answer(arr[l-1],have[0]);
return;
}
int mid=l+(r-l+1)*0.37,last;
vector<int>L,R;
if (!stay1){
for (int i=l-1;i<mid;i++){
last=Query(arr[i]);
alive[arr[i]]^=1;
}
}
else {
mid=r-(mid-l);
if (mid==r) mid--;
for (int i=mid;i<r;i++){
last=Query(arr[i]);
alive[arr[i]]^=1;
}
}
for (auto i:have){
if (L.size()==(mid-l+1)){
R.push_back(i);
continue;
}
if (R.size()==(r-mid)){
L.push_back(i);
continue;
}
int now=Query(i);
alive[i]^=1;
bool ty=(now==last);
if (ty)
L.push_back(i);
else R.push_back(i);
last=now;
}
Merge(mid+1,r,R,0);
Merge(l,mid,L,1);
}
void Solve(int N){
n=N;
vector<int>qry;
int last=-1;
for (int i=1;i<=2*N;i++){
if (arr.size()==N){
qry.push_back(i);
continue;
}
int now=Query(i);
alive[i]^=1;
if (now==last)
qry.push_back(i);
else {
arr.push_back(i);
last=now;
}
}
shuffle(arr.begin(),arr.end(),rng);
shuffle(qry.begin(),qry.end(),rng);
Merge(1,N,qry,1);
}
/*
g++ -std=gnu++14 -O2 -o grader grader.cpp minerals.cpp
./grader.exe
./rand.exe
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... |