답안 #994922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994922 2024-06-08T08:34:25 Z NintsiChkhaidze 도서관 (JOI18_library) C++17
19 / 100
242 ms 428 KB
#include "library.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int n;
 
void Solve(int N){
	n = N;
	
	vector<int> ans(N),fix(N),del(N);
	for(int i = 0; i < N; i++) {
		ans[i] = fix[i] = 0;
	}
	
	int cnt = 0;
	for (int i = 0; i < N; i++){
		vector <int> M(N);
		for (int j=0;j<N;j++){
			M[j] = 1;
		}
		
		M[i] = 0;
		int A;
		if (N == 1) A = 1;
		else A = Query(M);
		 
		if (A == 1){
			++cnt;
			fix[i] = 1;
			if (cnt == 1) ans[0] = i;
			else {ans[N - 1] = i; break;}
		}
	}
	
	for (int i = 0; i + 2 < N; i++){
 
		int find = 0;
		for (int j = 0; j < 10; j++){
			vector <int> M(N);
			int ones=0;
			for (int w = 0; w < N; w++){
				M[w] = 0;
				if (fix[w]) M[w] = 0;
				else {
					int bt = ((w >> j) & 1);
					if (bt) M[w] = 1,++ones;
				}
			}
			
			if (ones == 0) continue;
			M[ans[i]] = 1;
		
			int A = Query(M);
			
			M[ans[i]] = 0;
			int B = 0;
			if (ones > 1) B = Query(M);
			else B = 1;
			if (A == B) find |= (1<<j);
		}
		
		fix[find] = 1;
		ans[i + 1] = find;
	}
	
	for (int i=0;i<N;i++)
		ans[i] += 1;
	Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB # of queries: 3130
2 Correct 35 ms 344 KB # of queries: 3139
3 Correct 42 ms 344 KB # of queries: 3299
4 Correct 28 ms 344 KB # of queries: 3232
5 Correct 36 ms 344 KB # of queries: 3312
6 Correct 27 ms 344 KB # of queries: 3240
7 Correct 36 ms 344 KB # of queries: 3308
8 Correct 27 ms 344 KB # of queries: 3088
9 Correct 32 ms 344 KB # of queries: 3277
10 Correct 20 ms 344 KB # of queries: 1966
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 95
16 Correct 2 ms 344 KB # of queries: 259
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB # of queries: 3130
2 Correct 35 ms 344 KB # of queries: 3139
3 Correct 42 ms 344 KB # of queries: 3299
4 Correct 28 ms 344 KB # of queries: 3232
5 Correct 36 ms 344 KB # of queries: 3312
6 Correct 27 ms 344 KB # of queries: 3240
7 Correct 36 ms 344 KB # of queries: 3308
8 Correct 27 ms 344 KB # of queries: 3088
9 Correct 32 ms 344 KB # of queries: 3277
10 Correct 20 ms 344 KB # of queries: 1966
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 95
16 Correct 2 ms 344 KB # of queries: 259
17 Runtime error 242 ms 428 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -