답안 #338437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338437 2020-12-23T06:10:57 Z alishahali1382 도서관 (JOI18_library) C++14
100 / 100
377 ms 492 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
#define pb push_back

void Solve(int n){
	vector<int> M(n, 1), mark(n, 0);
	vector<int> A;
	if (n==1){
		A={1};
		Answer(A);
		return ;
	}
	for (int i=1; i<=n; i++){
		M[i-1]--;
		if (Query(M)==1){
			A.pb(i);
			mark[i-1]=1;
			break ;
		}
		M[i-1]++;
	}
//	cerr<<"A[0]="<<A[0]<<"\n";
	while (A.size()<n){
		vector<int> vec;
		for (int i=1; i<=n; i++) if (!mark[i-1]) vec.pb(i);
//		cerr<<"vec: ";for (int x:vec) cerr<<x<<" ";cerr<<"\n";
		int dwn=0, up=vec.size();
		while (up-dwn>1){
			int mid=(dwn+up)>>1;
			fill(M.begin(), M.end(), 0);
			for (int i=0; i<mid; i++) M[vec[i]-1]++;
			int val=Query(M);
			M[A.back()-1]++;
			if (Query(M)==val) up=mid;
			else dwn=mid;
		}
		A.pb(vec[dwn]);
		mark[vec[dwn]-1]++;
	}
	
	Answer(A);
}
/*
5
4 2 5 3 1

*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:24:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |  while (A.size()<n){
      |         ~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 364 KB # of queries: 2375
2 Correct 36 ms 364 KB # of queries: 2409
3 Correct 38 ms 364 KB # of queries: 2648
4 Correct 30 ms 376 KB # of queries: 2595
5 Correct 41 ms 364 KB # of queries: 2508
6 Correct 37 ms 364 KB # of queries: 2551
7 Correct 37 ms 364 KB # of queries: 2544
8 Correct 36 ms 384 KB # of queries: 2420
9 Correct 40 ms 364 KB # of queries: 2546
10 Correct 19 ms 364 KB # of queries: 1474
11 Correct 0 ms 364 KB # of queries: 0
12 Correct 1 ms 364 KB # of queries: 1
13 Correct 1 ms 364 KB # of queries: 4
14 Correct 1 ms 384 KB # of queries: 7
15 Correct 2 ms 364 KB # of queries: 77
16 Correct 3 ms 364 KB # of queries: 183
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 364 KB # of queries: 2375
2 Correct 36 ms 364 KB # of queries: 2409
3 Correct 38 ms 364 KB # of queries: 2648
4 Correct 30 ms 376 KB # of queries: 2595
5 Correct 41 ms 364 KB # of queries: 2508
6 Correct 37 ms 364 KB # of queries: 2551
7 Correct 37 ms 364 KB # of queries: 2544
8 Correct 36 ms 384 KB # of queries: 2420
9 Correct 40 ms 364 KB # of queries: 2546
10 Correct 19 ms 364 KB # of queries: 1474
11 Correct 0 ms 364 KB # of queries: 0
12 Correct 1 ms 364 KB # of queries: 1
13 Correct 1 ms 364 KB # of queries: 4
14 Correct 1 ms 384 KB # of queries: 7
15 Correct 2 ms 364 KB # of queries: 77
16 Correct 3 ms 364 KB # of queries: 183
17 Correct 319 ms 364 KB # of queries: 17982
18 Correct 335 ms 364 KB # of queries: 17293
19 Correct 345 ms 364 KB # of queries: 17467
20 Correct 314 ms 364 KB # of queries: 16325
21 Correct 288 ms 364 KB # of queries: 15324
22 Correct 377 ms 384 KB # of queries: 17669
23 Correct 340 ms 492 KB # of queries: 17224
24 Correct 157 ms 492 KB # of queries: 7915
25 Correct 346 ms 364 KB # of queries: 17136
26 Correct 337 ms 392 KB # of queries: 15963
27 Correct 144 ms 364 KB # of queries: 8040
28 Correct 246 ms 364 KB # of queries: 15957
29 Correct 290 ms 392 KB # of queries: 15939
30 Correct 288 ms 364 KB # of queries: 15957