답안 #348227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
348227 2021-01-14T11:30:33 Z jamielim 도서관 (JOI18_library) C++14
0 / 100
43 ms 384 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;
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;
			//printf("%d ",ans[0]);
			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;
				//printf("%d ",ans[j]);
			}
			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 32 ms 364 KB # of queries: 2387
2 Correct 43 ms 364 KB # of queries: 2433
3 Correct 38 ms 364 KB # of queries: 2638
4 Correct 34 ms 364 KB # of queries: 2593
5 Correct 37 ms 364 KB # of queries: 2504
6 Correct 28 ms 364 KB # of queries: 2553
7 Correct 37 ms 364 KB # of queries: 2568
8 Correct 37 ms 384 KB # of queries: 2402
9 Correct 35 ms 364 KB # of queries: 2512
10 Correct 19 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 32 ms 364 KB # of queries: 2387
2 Correct 43 ms 364 KB # of queries: 2433
3 Correct 38 ms 364 KB # of queries: 2638
4 Correct 34 ms 364 KB # of queries: 2593
5 Correct 37 ms 364 KB # of queries: 2504
6 Correct 28 ms 364 KB # of queries: 2553
7 Correct 37 ms 364 KB # of queries: 2568
8 Correct 37 ms 384 KB # of queries: 2402
9 Correct 35 ms 364 KB # of queries: 2512
10 Correct 19 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 -