답안 #347825

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
347825 2021-01-13T14:43:31 Z jamielim 도서관 (JOI18_library) C++14
0 / 100
47 ms 492 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;

int n;
vector<int> ans;

void dnc(int idx,vector<int> rem){
	if(SZ(rem)==1){
		ans[idx]=rem[0]+1;
		return;
	}
	int m=(SZ(rem)-1)/2;
	vector<int> q;
	for(int i=0;i<n;i++)q.pb(0);
	for(int i=0;i<=m;i++)q[rem[i]]=1;
	int cur=Query(q);
	for(int i=0;i<idx;i++)q[ans[i]-1]=1;
	if(cur==Query(q)){
		vector<int> l;
		for(int i=0;i<=m;i++)l.pb(rem[i]);
		dnc(idx,l);
	}else{
		vector<int> r;
		for(int i=m+1;i<SZ(rem);i++)r.pb(rem[i]);
		dnc(idx,r);
	}
}

void Solve(int N){
	n=N;
	ans.resize(n);
	vector<int> m(N);
	for(int i=0;i<n;i++)m[i]=1;
	for(int i=0;i<n;i++){
		m[i]=0;
		if(Query(m)==1){
			ans[0]=i+1;
			vector<int> v;
			for(int j=0;j<n;j++)if(j!=i)v.pb(j);
			//printf("%d ",ans[0]);
			for(int j=1;j<n;j++){
				dnc(j,v);
				vector<int> temp;
				for(int k=0;k<SZ(v);k++){
					if(v[k]==ans[j]-1)continue;
					temp.pb(v[k]);
				}
				v=temp;
				//printf("%d ",ans[j]);
			}
			Answer(ans);
			return;
		}
		m[i]=1;
	}
}
/*
5
4
2
5
3
1

9
7
2
1
6
4
8
3
9
5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 492 KB # of queries: 2387
2 Correct 44 ms 364 KB # of queries: 2433
3 Correct 39 ms 364 KB # of queries: 2638
4 Correct 40 ms 364 KB # of queries: 2593
5 Correct 43 ms 364 KB # of queries: 2504
6 Correct 47 ms 364 KB # of queries: 2553
7 Correct 28 ms 376 KB # of queries: 2568
8 Correct 38 ms 364 KB # of queries: 2402
9 Correct 40 ms 364 KB # of queries: 2512
10 Correct 20 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 35 ms 492 KB # of queries: 2387
2 Correct 44 ms 364 KB # of queries: 2433
3 Correct 39 ms 364 KB # of queries: 2638
4 Correct 40 ms 364 KB # of queries: 2593
5 Correct 43 ms 364 KB # of queries: 2504
6 Correct 47 ms 364 KB # of queries: 2553
7 Correct 28 ms 376 KB # of queries: 2568
8 Correct 38 ms 364 KB # of queries: 2402
9 Correct 40 ms 364 KB # of queries: 2512
10 Correct 20 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 -