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>
//#include "grader.cpp"
using namespace std;
//Query(int)
//Answer(int,int)
int last=0;
int ask(int k){
int p = Query(k);
int tmp = p - last;
last = p;
return tmp;
}
void dc(vector<int> &a,vector<int> &b,int t){
int n=a.size();
if(n==1){
Answer(a[0],b[0]);
return;
}
int r=__lg(n-1);
int m=1<<r;
if(t>0){
for(int i=m;i<n;i++){
ask(a[i]);
}
}
else{
for(int i=0;i<m;i++){
ask(a[i]);
}
}
vector<int> a1,a2,b1,b2;
for(int i=0;i<m;i++){
a1.push_back(a[i]);
}
for(int i=m;i<n;i++){
a2.push_back(a[i]);
}
for(int i=0;i<n;i++){
if(ask(b[i])==0){
b1.push_back(b[i]);
}
else{
b2.push_back(b[i]);
}
}
if(t==0){
dc(a1,b1,2);
dc(b2,a2,1);
}
if(t==1){
dc(a1,b1,2);
dc(b2,a2,1);
}
if(t==2){
dc(a1,b1,1);
dc(a2,b2,0);
}
}
void Solve(int n) {
vector<int> a,b;
for(int i=1;i<=n*2;i++){
if(ask(i)==0){
b.push_back(i);
}
else{
a.push_back(i);
}
}
dc(a,b,2);
}
/*
6
1 2
3 4
5 6
8 7
10 9
11 12
*/
# | 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... |