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;
set<int>st;
int query(int k){
if(st.count(k))
st.erase(k);
else st.insert(k);
return Query(k);
}
mt19937 rng(random_device{}());
void solve(vector<int>A,vector<int>B,int dep){
if(A.size()==1) return Answer(A[0],B[0]);
vector<int>A1,A2;
vector<int>B1,B2;
for(auto i:A)
A1.push_back(i),swap(A1,A2);
int prv=0;
for(auto i:A1)
prv=query(i);
shuffle(B.begin(),B.end(),rng);
for(auto i:B) {
if(A1.size()==B1.size()){
B2.push_back(i);
continue;
} else if(A2.size()==B2.size()){
B1.push_back(i);
continue;
}
int x=query(i);
if(st.count(A1[0])^(x==prv))
B2.push_back(i);
else B1.push_back(i);
prv=x;
}
solve(A1,B1,dep^1);
solve(A2,B2,dep^1);
}
void Solve(int N) {
vector<int>A,B;
int prv=0;
for(int i=1;i<=2*N;i++)
if(query(i)!=prv)
A.push_back(i),prv++;
else B.push_back(i);
solve(A,B,0);
}
# | 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... |