답안 #550588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550588 2022-04-18T15:45:49 Z Pherokung 도서관 (JOI18_library) C++14
100 / 100
494 ms 424 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int st=0,vis[1005];
void Solve(int n){
	vector<int> res;
	if(n == 1){
		res.push_back(1);
		Answer(res);
		return;
	}
	vector<int> M(n), K, K2;
	
	K = M; 
	for(int i=1;i<=n;i++) K[i-1] = 1;
	for(int i=1;i<=n;i++){
		K[i-1] = 0;
		if(Query(K) == 1){
			st = i;
			break;
		}
		K[i-1] = 1;
	}
	
	int pos = st,pre = -1;
	for(int i=1;i<=n;i++){
		res.push_back(pos);
		vis[pos] = 1;
		
		int be = 1,ed = n-i, mid, mi = 1e9, keep = pos;

		while(be <= ed){
			mid = (be+ed)/2;
			K = M;
			int cnt = 0;
			for(int j=1;j<=n;j++) if(vis[j] == 0 && cnt < mid) K[j-1] = 1, cnt++;
			K2 = K;
			K[pos-1] = 1, K2[pos-1] = 0;
			int A,B;
			if(K2 == M) A = 0, B = 1;
			else A = Query(K2), B = Query(K);
			if(B == A){
				ed = mid - 1;
				mi = min(mi,mid);
			}
			else be = mid + 1;
		}
		int cnt = 0;
		for(int j=1;j<=n;j++) if(vis[j] == 0 && cnt < mi) pos = j,cnt++;
		pre = keep;
	}
	
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:27:15: warning: variable 'pre' set but not used [-Wunused-but-set-variable]
   27 |  int pos = st,pre = -1;
      |               ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 208 KB # of queries: 2401
2 Correct 33 ms 208 KB # of queries: 2437
3 Correct 38 ms 208 KB # of queries: 2658
4 Correct 48 ms 308 KB # of queries: 2597
5 Correct 37 ms 208 KB # of queries: 2526
6 Correct 24 ms 304 KB # of queries: 2565
7 Correct 37 ms 208 KB # of queries: 2556
8 Correct 36 ms 208 KB # of queries: 2424
9 Correct 35 ms 304 KB # of queries: 2550
10 Correct 22 ms 304 KB # of queries: 1488
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 6
14 Correct 1 ms 208 KB # of queries: 9
15 Correct 1 ms 208 KB # of queries: 79
16 Correct 3 ms 208 KB # of queries: 195
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 208 KB # of queries: 2401
2 Correct 33 ms 208 KB # of queries: 2437
3 Correct 38 ms 208 KB # of queries: 2658
4 Correct 48 ms 308 KB # of queries: 2597
5 Correct 37 ms 208 KB # of queries: 2526
6 Correct 24 ms 304 KB # of queries: 2565
7 Correct 37 ms 208 KB # of queries: 2556
8 Correct 36 ms 208 KB # of queries: 2424
9 Correct 35 ms 304 KB # of queries: 2550
10 Correct 22 ms 304 KB # of queries: 1488
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 6
14 Correct 1 ms 208 KB # of queries: 9
15 Correct 1 ms 208 KB # of queries: 79
16 Correct 3 ms 208 KB # of queries: 195
17 Correct 494 ms 416 KB # of queries: 18030
18 Correct 385 ms 312 KB # of queries: 17279
19 Correct 440 ms 304 KB # of queries: 17479
20 Correct 392 ms 296 KB # of queries: 16301
21 Correct 346 ms 300 KB # of queries: 15352
22 Correct 472 ms 304 KB # of queries: 17663
23 Correct 410 ms 300 KB # of queries: 17250
24 Correct 166 ms 288 KB # of queries: 7917
25 Correct 442 ms 300 KB # of queries: 17158
26 Correct 413 ms 424 KB # of queries: 16003
27 Correct 127 ms 288 KB # of queries: 8046
28 Correct 372 ms 208 KB # of queries: 15975
29 Correct 354 ms 300 KB # of queries: 15957
30 Correct 364 ms 312 KB # of queries: 15975