Submission #347232

# Submission time Handle Problem Language Result Execution time Memory
347232 2021-01-12T11:40:04 Z zaneyu Library (JOI18_library) C++14
100 / 100
369 ms 620 KB
#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
1 Correct 38 ms 364 KB # of queries: 2387
2 Correct 34 ms 364 KB # of queries: 2433
3 Correct 37 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 36 ms 364 KB # of queries: 2504
6 Correct 35 ms 364 KB # of queries: 2553
7 Correct 46 ms 364 KB # of queries: 2568
8 Correct 41 ms 364 KB # of queries: 2402
9 Correct 35 ms 364 KB # of queries: 2512
10 Correct 21 ms 364 KB # of queries: 1478
11 Correct 1 ms 364 KB # of queries: 0
12 Correct 0 ms 364 KB # of queries: 1
13 Correct 1 ms 384 KB # of queries: 4
14 Correct 1 ms 364 KB # of queries: 7
15 Correct 1 ms 364 KB # of queries: 73
16 Correct 4 ms 364 KB # of queries: 187
# Verdict Execution time Memory Grader output
1 Correct 38 ms 364 KB # of queries: 2387
2 Correct 34 ms 364 KB # of queries: 2433
3 Correct 37 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 36 ms 364 KB # of queries: 2504
6 Correct 35 ms 364 KB # of queries: 2553
7 Correct 46 ms 364 KB # of queries: 2568
8 Correct 41 ms 364 KB # of queries: 2402
9 Correct 35 ms 364 KB # of queries: 2512
10 Correct 21 ms 364 KB # of queries: 1478
11 Correct 1 ms 364 KB # of queries: 0
12 Correct 0 ms 364 KB # of queries: 1
13 Correct 1 ms 384 KB # of queries: 4
14 Correct 1 ms 364 KB # of queries: 7
15 Correct 1 ms 364 KB # of queries: 73
16 Correct 4 ms 364 KB # of queries: 187
17 Correct 321 ms 492 KB # of queries: 18008
18 Correct 340 ms 492 KB # of queries: 17231
19 Correct 328 ms 492 KB # of queries: 17451
20 Correct 334 ms 492 KB # of queries: 16277
21 Correct 288 ms 492 KB # of queries: 15362
22 Correct 334 ms 516 KB # of queries: 17617
23 Correct 318 ms 492 KB # of queries: 17170
24 Correct 143 ms 492 KB # of queries: 7885
25 Correct 357 ms 620 KB # of queries: 17118
26 Correct 326 ms 492 KB # of queries: 15989
27 Correct 146 ms 364 KB # of queries: 7994
28 Correct 295 ms 492 KB # of queries: 17935
29 Correct 369 ms 364 KB # of queries: 17915
30 Correct 317 ms 492 KB # of queries: 17935