Submission #347215

# Submission time Handle Problem Language Result Execution time Memory
347215 2021-01-12T11:25:10 Z zaneyu Library (JOI18_library) C++14
0 / 100
45 ms 364 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;
}
void Solve(int n){
	int rt=0;
	REP(i,n){
		vector<int> v;
		v.resize(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;
			vector<int> v;
			v.resize(n);
			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 35 ms 364 KB # of queries: 2387
2 Correct 38 ms 364 KB # of queries: 2433
3 Correct 38 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 41 ms 364 KB # of queries: 2504
6 Correct 26 ms 364 KB # of queries: 2553
7 Correct 37 ms 364 KB # of queries: 2568
8 Correct 35 ms 364 KB # of queries: 2402
9 Correct 40 ms 364 KB # of queries: 2512
10 Correct 25 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 -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 364 KB # of queries: 2387
2 Correct 38 ms 364 KB # of queries: 2433
3 Correct 38 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 41 ms 364 KB # of queries: 2504
6 Correct 26 ms 364 KB # of queries: 2553
7 Correct 37 ms 364 KB # of queries: 2568
8 Correct 35 ms 364 KB # of queries: 2402
9 Correct 40 ms 364 KB # of queries: 2512
10 Correct 25 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 -