답안 #654364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654364 2022-10-31T07:53:05 Z SanguineChameleon 도서관 (JOI18_library) C++14
100 / 100
515 ms 328 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n) {
	if (n == 1) {
		Answer({1});
		return;
	}
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		a[i] = 1;
	}
	int px = -1;
	for (int i = 0; i < n; i++) {
		a[i] = 0;
		if (Query(a) == 1) {
			px = i + 1;
		}
		a[i] = 1;
	}
	vector<int> res(n);
	res[0] = px;
	vector<int> p(n);
	iota(p.begin(), p.end(), 1);
	p.erase(find(p.begin(), p.end(), px));
	for (int i = 1; i < n; i++) {
		int lt = 0;
		int rt = (int)p.size() - 1;
		int pt = -1;
		while (lt <= rt) {
			int mt = (lt + rt) / 2;
			fill(a.begin(), a.end(), 0);
			for (int j = 0; j <= mt; j++) {
				a[p[j] - 1] = 1;
			}
			int d1 = Query(a);
			a[px - 1] = 1;
			int d2 = Query(a);
			if (d1 == d2) {
				pt = mt;
				rt = mt - 1;
			}
			else {
				lt = mt + 1;
			}
		}
		res[i] = (px = p[pt]);
		p.erase(find(p.begin(), p.end(), px));
	}
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 208 KB # of queries: 2586
2 Correct 47 ms 296 KB # of queries: 2555
3 Correct 51 ms 208 KB # of queries: 2716
4 Correct 39 ms 208 KB # of queries: 2728
5 Correct 38 ms 208 KB # of queries: 2714
6 Correct 35 ms 208 KB # of queries: 2712
7 Correct 42 ms 208 KB # of queries: 2718
8 Correct 48 ms 208 KB # of queries: 2611
9 Correct 23 ms 300 KB # of queries: 2713
10 Correct 19 ms 208 KB # of queries: 1597
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 328 KB # of queries: 4
13 Correct 1 ms 208 KB # of queries: 7
14 Correct 1 ms 208 KB # of queries: 14
15 Correct 2 ms 208 KB # of queries: 99
16 Correct 3 ms 208 KB # of queries: 205
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 208 KB # of queries: 2586
2 Correct 47 ms 296 KB # of queries: 2555
3 Correct 51 ms 208 KB # of queries: 2716
4 Correct 39 ms 208 KB # of queries: 2728
5 Correct 38 ms 208 KB # of queries: 2714
6 Correct 35 ms 208 KB # of queries: 2712
7 Correct 42 ms 208 KB # of queries: 2718
8 Correct 48 ms 208 KB # of queries: 2611
9 Correct 23 ms 300 KB # of queries: 2713
10 Correct 19 ms 208 KB # of queries: 1597
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 328 KB # of queries: 4
13 Correct 1 ms 208 KB # of queries: 7
14 Correct 1 ms 208 KB # of queries: 14
15 Correct 2 ms 208 KB # of queries: 99
16 Correct 3 ms 208 KB # of queries: 205
17 Correct 461 ms 208 KB # of queries: 18160
18 Correct 442 ms 284 KB # of queries: 17933
19 Correct 444 ms 208 KB # of queries: 18178
20 Correct 417 ms 208 KB # of queries: 16960
21 Correct 336 ms 208 KB # of queries: 15937
22 Correct 487 ms 208 KB # of queries: 18168
23 Correct 483 ms 208 KB # of queries: 18157
24 Correct 157 ms 304 KB # of queries: 8321
25 Correct 396 ms 208 KB # of queries: 17675
26 Correct 310 ms 208 KB # of queries: 16597
27 Correct 156 ms 208 KB # of queries: 8287
28 Correct 515 ms 208 KB # of queries: 18954
29 Correct 350 ms 284 KB # of queries: 18933
30 Correct 440 ms 208 KB # of queries: 18954