답안 #606247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
606247 2022-07-26T05:47:37 Z alireza_kaviani 도서관 (JOI18_library) C++17
0 / 100
44 ms 352 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 j = 0 ; j < lg ; j++){
			vector<int> Q;
			for(int k = 0 ; k < SZ(vec) ; k++){
				if(k & (1 << j)){
					Q.push_back(vec[k]);
				}
			}
			for(int k : Q){
				M[k] = 1;
			}
			int A = Query(M);
			M[res.back()] = 0;
			int B = Query(M);
			M[res.back()] = 1;
			for(int k : Q){
				M[k] = 0;
			}
			if(A != B){
				ind |= (1 << j);
			}
		}
		res.push_back(vec[ind]);
	}
	for(int i = 0 ; i < n ; i++){
		res[i]++;
	}
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 352 KB # of queries: 2722
2 Correct 21 ms 304 KB # of queries: 2773
3 Correct 37 ms 208 KB # of queries: 2983
4 Correct 28 ms 300 KB # of queries: 2948
5 Correct 31 ms 300 KB # of queries: 2863
6 Correct 44 ms 208 KB # of queries: 2910
7 Correct 35 ms 300 KB # of queries: 2919
8 Correct 40 ms 300 KB # of queries: 2750
9 Correct 38 ms 300 KB # of queries: 2892
10 Correct 20 ms 336 KB # of queries: 1686
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 352 KB # of queries: 2722
2 Correct 21 ms 304 KB # of queries: 2773
3 Correct 37 ms 208 KB # of queries: 2983
4 Correct 28 ms 300 KB # of queries: 2948
5 Correct 31 ms 300 KB # of queries: 2863
6 Correct 44 ms 208 KB # of queries: 2910
7 Correct 35 ms 300 KB # of queries: 2919
8 Correct 40 ms 300 KB # of queries: 2750
9 Correct 38 ms 300 KB # of queries: 2892
10 Correct 20 ms 336 KB # of queries: 1686
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -