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;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = -1;
const int inf=1000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
int n;
vector<int> v1,v2;
set<int> s;
vector<pair<int,int>> out;
int lst;
void dnc(vector<int> L, vector<int> R){
//debug(L.size(),R.size());
if(L.size() == 1 && R.size() == 1){
out.push_back({L[0],R[0]});
return;
}
int mi=(int)R.size()/2;
vector<int> Llf, Lrg, Rlf, Rrg;
unordered_set<int> w1;
for(int i=0;i<mi;i++){ // [0,mi) is the set i want to query
w1.insert(R[i]);
if(s.find(R[i]) == s.end()){
//debug(__LINE__,R[i]);
lst=Query(R[i]);
s.insert(R[i]);
}
}
vector<int> del;
for(auto x:s){
if(w1.find(x) == w1.end()){
del.push_back(x);
}
}
for(auto x:del){
//debug(__LINE__,x);
lst=Query(x);
s.erase(x);
}
for(auto x:L){
int q=Query(x);
//debug(x);
//debug(x,lst,q);
Query(x);
if(q==lst){
Llf.push_back(x);
} else{
Lrg.push_back(x);
}
}
for(int i=0;i<mi;i++){
Rlf.push_back(R[i]);
}
for(int i=mi;i<(int)R.size();i++){
Rrg.push_back(R[i]);
}
dnc(Llf,Rlf);
dnc(Lrg,Rrg);
}
void Solve(int N) {
n=N;
for(int i=1;i<=2*n;i++){
if(i<=n)v1.push_back(i);
else v2.push_back(i);
}
dnc(v1,v2);
for(auto x:out){
Answer(x.first,x.second);
}
}
# | 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... |