#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);
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
24 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
41 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
33 ms |
364 KB |
# of queries: 2504 |
6 |
Correct |
43 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
37 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
33 ms |
492 KB |
# of queries: 2402 |
9 |
Correct |
34 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
21 ms |
364 KB |
# of queries: 1478 |
11 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
24 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
41 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
33 ms |
364 KB |
# of queries: 2504 |
6 |
Correct |
43 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
37 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
33 ms |
492 KB |
# of queries: 2402 |
9 |
Correct |
34 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
21 ms |
364 KB |
# of queries: 1478 |
11 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |