답안 #348233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
348233 2021-01-14T11:35:38 Z jamielim 도서관 (JOI18_library) C++17
0 / 100
57 ms 364 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

int n;
vector<int> ans;
bitset<1005> rem;
vector<int> q;

void dnc(int idx,int sz){
	if(sz<=1){
		for(int i=0;i<n;i++)if(rem[i]){ans[idx]=i;break;}
		return;
	}
	int m=(sz-1)/2;
	for(int i=0;i<n;i++)q[i]=0;
	int x=0;
	for(int i=0;i<n&&x<=m;i++)if(rem[i]){q[i]=1;x++;}
	int cur=Query(q);
	for(int i=0;i<idx;i++)q[ans[i]]=1;
	if(cur==Query(q)){
		x=0;
		for(int i=0;i<n;i++){
			if(rem[i]){
				if(x>m){
					rem[i]=0;
				}
				x++;
			}
		}
		dnc(idx,m+1);
	}else{
		x=0;
		for(int i=0;i<n;i++){
			if(rem[i]){
				if(x<=m){
					rem[i]=0;
				}
				x++;
			}
		}
		dnc(idx,sz-m-1);
	}
}

void Solve(int N){
	n=N;
	ans.resize(n);
	q.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;
			for(int j=1;j<n;j++){
				for(int k=0;k<n;k++){
					rem[k]=(m[k]==1?1:0);
				}
				dnc(j,n-j);
				assert(ans[j]>=0&&ans[j]<n);
				m[ans[j]]=0;
			}
			for(int j=0;j<n;j++)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 38 ms 364 KB # of queries: 2387
2 Correct 35 ms 364 KB # of queries: 2433
3 Correct 48 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 57 ms 364 KB # of queries: 2504
6 Correct 26 ms 364 KB # of queries: 2553
7 Correct 44 ms 364 KB # of queries: 2568
8 Correct 40 ms 364 KB # of queries: 2402
9 Correct 44 ms 364 KB # of queries: 2512
10 Correct 25 ms 364 KB # of queries: 1478
11 Runtime error 1 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 38 ms 364 KB # of queries: 2387
2 Correct 35 ms 364 KB # of queries: 2433
3 Correct 48 ms 364 KB # of queries: 2638
4 Correct 45 ms 364 KB # of queries: 2593
5 Correct 57 ms 364 KB # of queries: 2504
6 Correct 26 ms 364 KB # of queries: 2553
7 Correct 44 ms 364 KB # of queries: 2568
8 Correct 40 ms 364 KB # of queries: 2402
9 Correct 44 ms 364 KB # of queries: 2512
10 Correct 25 ms 364 KB # of queries: 1478
11 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -