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 "library.h"
#include<bits/stdc++.h>
using namespace std;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll 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()
const ll maxn=2e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#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())
ll mult(ll a,ll b){
return (a*b)%MOD;
}
ll mypow(ll a,ll b){
if(b<=0) return 1;
a%=MOD;
ll res=1LL;
while(b){
if(b&1) res=mult(res,a);
a=mult(a,a);
b>>=1;
}
return res;
}
vector<int> v;
void Solve(int n){
int rt=0;
v.resize(n);
if(n==1){
v[0]=1;
Answer(v);
return;
}
REP(i,n){
REP(j,n) v[j]=1;
v[i]=0;
int z=Query(v);
if(z==1){
rt=i;
break;
}
}
vector<int> left;
REP(i,n) left.pb(i);
vector<int> ans;
left.erase(lower_bound(ALL(left),rt));
ans.pb(rt+1);
REP(i,n-1){
int l=0,r=sz(left)-1;
while(l<r){
int mid=(l+r)/2;
REP(j,n) v[j]=0;
v[rt]=1;
REP(j,mid+1) v[left[j]]=1;
int z=Query(v);
v[rt]=0;
int b=Query(v);
if(z==b+1){
l=mid+1;
}
else{
r=mid;
}
}
ans.pb(left[l]+1);
rt=left[l];
left.erase(left.begin()+l);
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |