답안 #606246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
606246 2022-07-26T05:45:02 Z alireza_kaviani 도서관 (JOI18_library) C++17
0 / 100
48 ms 336 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

#define all(x)	(x).begin(), (x).end()
#define SZ(x)	int((x).size())

void Solve(int n){
	vector<int> M(n , 1);
	vector<int> res;
	for(int i = 0 ; i < n ; i++){
		M[i] = 0;
		if(Query(M) <= 1){
			res.push_back(i);
			break;
		}
		M[i] = 1;
	}
	fill(all(M) , 0);
	M[res[0]] = 1;
	for(int i = 0 ; i < n ; i++){
		if(M[i])	continue;
		M[i] = 1;
		if(Query(M) <= 1){
			res.push_back(i);
			continue;
		}
		M[i] = 0;
	}
	for(int i = SZ(res) ; i < n ; i++){
		fill(all(M) , 0);
		vector<int> vec;
		for(int j : res){
			M[j] = 1;
		}
		for(int j = 0 ; j < n ; j++){
			if(!M[j]){
				vec.push_back(j);
			}
		}
		int lg = 0;
		while((1 << lg) < SZ(vec))	lg++;
		int ind = 0;
		for(int i = 0 ; i < lg ; i++){
			vector<int> Q;
			for(int j = 0 ; j < SZ(vec) ; j++){
				if(j & (1 << i)){
					Q.push_back(vec[j]);
				}
			}
			for(int j : Q){
				M[j] = 1;
			}
			int A = Query(M);
			M[res.back()] = 0;
			int B = Query(M);
			M[res.back()] = 1;
			for(int j : Q){
				M[j] = 0;
			}
			if(A != B){
				ind |= (1 << i);
			}
		}
		res.push_back(vec[ind]);
	}
	for(int i = 0 ; i < n ; i++){
		res[i]++;
	}
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 292 KB # of queries: 2722
2 Correct 41 ms 208 KB # of queries: 2773
3 Correct 42 ms 332 KB # of queries: 2983
4 Correct 48 ms 208 KB # of queries: 2948
5 Correct 43 ms 208 KB # of queries: 2863
6 Correct 47 ms 300 KB # of queries: 2910
7 Correct 23 ms 296 KB # of queries: 2919
8 Correct 38 ms 208 KB # of queries: 2750
9 Correct 39 ms 296 KB # of queries: 2892
10 Correct 19 ms 208 KB # of queries: 1686
11 Runtime error 0 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 292 KB # of queries: 2722
2 Correct 41 ms 208 KB # of queries: 2773
3 Correct 42 ms 332 KB # of queries: 2983
4 Correct 48 ms 208 KB # of queries: 2948
5 Correct 43 ms 208 KB # of queries: 2863
6 Correct 47 ms 300 KB # of queries: 2910
7 Correct 23 ms 296 KB # of queries: 2919
8 Correct 38 ms 208 KB # of queries: 2750
9 Correct 39 ms 296 KB # of queries: 2892
10 Correct 19 ms 208 KB # of queries: 1686
11 Runtime error 0 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -