Submission #606254

# Submission time Handle Problem Language Result Execution time Memory
606254 2022-07-26T05:49:27 Z alireza_kaviani Library (JOI18_library) C++17
100 / 100
418 ms 304 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);
	if(n == 1){
		Answer(M);
		return;
	}
	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);
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 208 KB # of queries: 2722
2 Correct 39 ms 208 KB # of queries: 2773
3 Correct 34 ms 304 KB # of queries: 2983
4 Correct 30 ms 296 KB # of queries: 2948
5 Correct 53 ms 280 KB # of queries: 2863
6 Correct 45 ms 208 KB # of queries: 2910
7 Correct 36 ms 208 KB # of queries: 2919
8 Correct 48 ms 208 KB # of queries: 2750
9 Correct 50 ms 208 KB # of queries: 2892
10 Correct 21 ms 300 KB # of queries: 1686
11 Correct 0 ms 284 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 0 ms 272 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 6
15 Correct 2 ms 208 KB # of queries: 73
16 Correct 4 ms 208 KB # of queries: 223
# Verdict Execution time Memory Grader output
1 Correct 40 ms 208 KB # of queries: 2722
2 Correct 39 ms 208 KB # of queries: 2773
3 Correct 34 ms 304 KB # of queries: 2983
4 Correct 30 ms 296 KB # of queries: 2948
5 Correct 53 ms 280 KB # of queries: 2863
6 Correct 45 ms 208 KB # of queries: 2910
7 Correct 36 ms 208 KB # of queries: 2919
8 Correct 48 ms 208 KB # of queries: 2750
9 Correct 50 ms 208 KB # of queries: 2892
10 Correct 21 ms 300 KB # of queries: 1686
11 Correct 0 ms 284 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 0 ms 272 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 6
15 Correct 2 ms 208 KB # of queries: 73
16 Correct 4 ms 208 KB # of queries: 223
17 Correct 396 ms 280 KB # of queries: 19773
18 Correct 360 ms 288 KB # of queries: 18989
19 Correct 418 ms 208 KB # of queries: 19178
20 Correct 313 ms 300 KB # of queries: 17996
21 Correct 317 ms 288 KB # of queries: 16968
22 Correct 342 ms 208 KB # of queries: 19392
23 Correct 278 ms 288 KB # of queries: 18972
24 Correct 154 ms 288 KB # of queries: 8757
25 Correct 274 ms 288 KB # of queries: 18848
26 Correct 312 ms 296 KB # of queries: 17671
27 Correct 154 ms 208 KB # of queries: 8906
28 Correct 16 ms 208 KB # of queries: 1000
29 Correct 14 ms 304 KB # of queries: 999
30 Correct 15 ms 208 KB # of queries: 1000