답안 #994878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994878 2024-06-08T07:59:37 Z NintsiChkhaidze 도서관 (JOI18_library) C++17
0 / 100
43 ms 596 KB
#include "library.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll B) {
	return (ull)rng() % B;
}
 
 
int n;

bool check(int x,int y){
	vector <int> M(n);
	M[x] = 1;
	M[y] = 1;
	
	return (Query(M) == 1);
}

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;
	}
	
	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 = Query(M);
		if (A == 1){
			fix[i] = 1;
			ans[0] = i;
			break;
		}
	}
	
	for (int i = 0; i + 1 < 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;
				}
			}
			
			M[ans[i]] = 1;
			ones++;
			int A = Query(M);
			
			M[ans[i]] = 0;
			ones--;
			int B;
			if (ones == 0) B = 0;
			else B = Query(M);
			
			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: 3643
2 Correct 35 ms 344 KB # of queries: 3660
3 Correct 30 ms 596 KB # of queries: 3917
4 Correct 43 ms 344 KB # of queries: 3863
5 Correct 27 ms 344 KB # of queries: 3776
6 Correct 25 ms 344 KB # of queries: 3828
7 Correct 29 ms 344 KB # of queries: 3834
8 Correct 30 ms 344 KB # of queries: 3666
9 Correct 43 ms 344 KB # of queries: 3806
10 Correct 17 ms 344 KB # of queries: 2458
11 Runtime error 0 ms 344 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB # of queries: 3643
2 Correct 35 ms 344 KB # of queries: 3660
3 Correct 30 ms 596 KB # of queries: 3917
4 Correct 43 ms 344 KB # of queries: 3863
5 Correct 27 ms 344 KB # of queries: 3776
6 Correct 25 ms 344 KB # of queries: 3828
7 Correct 29 ms 344 KB # of queries: 3834
8 Correct 30 ms 344 KB # of queries: 3666
9 Correct 43 ms 344 KB # of queries: 3806
10 Correct 17 ms 344 KB # of queries: 2458
11 Runtime error 0 ms 344 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -