# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710423 | Darren0724 | Minerals (JOI19_minerals) | C++17 | 0 ms | 0 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 "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<int> v;
void dc(vector<int> &a,vector<int> &c){
//cout<<a.size()<<' '<<c.size()<<endl;
if(a.size()==1){
v[a[0]]=c[0];
return;
}
int t=0;
int m=a.size()/2;
for(int i=0;i<m;i++){
t=Query(a[i]);
}
vector<int> c1,c2;
for(int i:c){
int t1=Query(i);
if(t1!=t){
Query(i);
c2.push_back(i);
}
else{
c1.push_back(i);
}
}
for(int i:c1){
Query(i);
}
for(int i=0;i<m;i++){
t=Query(a[i]);
}
vector<int> a1,a2;
for(int i=0;i<m;i++){
a1.push_back(a[i]);
}
for(int i=m;i<a.size();i++){
a2.push_back(a[i]);
}
dc(a1,c1);
dc(a2,c2);
}
void Solve(int N) {
n=N;
vector<int> a;
vector<int> c;
int t=0;
for(int i=1;i<=N*2;i++){
int t1=Query(i);
if(t1!=t){
a.push_back(i);
t++;
}
else{
c.push_back(i);
Query(i);
}
}
for(int i:a){
Query(i);
}
v.resize(N*2+1,-1);
dc(a,c);
for(int i=1;i<=n*2;i++){
if(v[i]!=-1)Answer(i,v[i]);
}
}