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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
mt19937 rng(3289);
int pv=0;
const int maxn=1e5+5;
bool in[maxn];
bool qr(int x){
in[x]^=1;
int asd=Query(x);
bool ok=(asd!=pv);
pv=asd;
return ok;
}
int asd=0;
void rec(vector<int> x,vector<int> y){
++asd;
if(!sz(x)) return;
if(sz(x)==1){
if(in[x[0]]) in[x[0]]=1;
Answer(x[0],y[0]);
return;
}
/* for(int a:x) cout<<a<<' ';
cout<<'\n';
for(int a:y) cout<<a<<' ';
cout<<'\n';*/
vector<int> xl,xr,yl,yr;
int mid=ceil(sz(x)*0.4);
//cout<<mid;
if(in[x[0]]){
REP(i,mid) qr(x[sz(x)-i-1]);
mid=sz(x)-mid;
}
else REP(i,mid) qr(x[i]);
REP(i,mid) xl.pb(x[i]);
for(int i=mid;i<sz(x);i++) xr.pb(x[i]);
shuffle(ALL(y),rng);
for(int a:y){
if(sz(yl)==mid){
yr.pb(a);
continue;
}
if(sz(yr)==sz(x)-mid){
yl.pb(a);
continue;
}
if(!qr(a)){
yl.pb(a);
}
else yr.pb(a);
}
rec(xl,yl);
rec(xr,yr);
}
void Solve(int n) {
vector<int> x,y;
REP1(i,2*n){
if(qr(i)){
x.pb(i);
}
else y.pb(i);
}
rec(x,y);
}
# | 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... |