Submission #1097505

# Submission time Handle Problem Language Result Execution time Memory
1097505 2024-10-07T13:51:11 Z Alihan_8 Library (JOI18_library) C++17
100 / 100
254 ms 848 KB
#include "library.h"

#include <bits/stdc++.h>

using namespace std;

#define pb push_back

int n;

int qry(vector <int> p){
	vector <int> M(n);
	
	for ( auto &x: p ) M[x] = 1;
	
	return Query(M);
}

void Solve(int N){ 
	if ( N == 1 ){
		vector <int> res = {1};
		Answer(res);
		return;
	}
	
	n = N;
	
	int st = -1;
	
	vector <int> M(n, 1), res(n);
	
	for ( int i = 0; i < n; i++ ){
		M[i] = 0;
		if ( Query(M) == 1 ){
			st = i; break;
		} M[i] = 1;
	}
	
	vector <int> chk(n);
	
	res[0] = st; chk[st] = 1;
	
	for ( int i = 1; i < n; i++ ){
		vector <int> q;
		
		for ( int j = 0; j < n; j++ ){
			if ( !chk[j] ) q.pb(j);
		}
		
		int u = 0, m = q.size();
		
		for ( int lg = 0; lg <= 10; lg++ ){
			vector <int> t;
			
			for ( int j = 0; j < m; j++ ){
				if ( j >> lg & 1 ) t.pb(q[j]);
			}
			
			if ( t.empty() ) continue;
			
			int w = qry(t); t.pb(res[i - 1]);
			
			if ( w == qry(t) ){
				u |= 1 << lg;
			}
		}
		
		res[i] = q[u]; chk[q[u]] = 1;
	}
	
	for ( auto &x: res ) x++;
	
	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 344 KB # of queries: 2563
2 Correct 25 ms 600 KB # of queries: 2599
3 Correct 16 ms 344 KB # of queries: 2816
4 Correct 22 ms 344 KB # of queries: 2765
5 Correct 36 ms 344 KB # of queries: 2680
6 Correct 21 ms 340 KB # of queries: 2727
7 Correct 18 ms 344 KB # of queries: 2736
8 Correct 25 ms 344 KB # of queries: 2590
9 Correct 29 ms 444 KB # of queries: 2710
10 Correct 11 ms 344 KB # of queries: 1572
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 1 ms 344 KB # of queries: 1
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 83
16 Correct 3 ms 344 KB # of queries: 207
# Verdict Execution time Memory Grader output
1 Correct 15 ms 344 KB # of queries: 2563
2 Correct 25 ms 600 KB # of queries: 2599
3 Correct 16 ms 344 KB # of queries: 2816
4 Correct 22 ms 344 KB # of queries: 2765
5 Correct 36 ms 344 KB # of queries: 2680
6 Correct 21 ms 340 KB # of queries: 2727
7 Correct 18 ms 344 KB # of queries: 2736
8 Correct 25 ms 344 KB # of queries: 2590
9 Correct 29 ms 444 KB # of queries: 2710
10 Correct 11 ms 344 KB # of queries: 1572
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 1 ms 344 KB # of queries: 1
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 83
16 Correct 3 ms 344 KB # of queries: 207
17 Correct 246 ms 604 KB # of queries: 18794
18 Correct 246 ms 468 KB # of queries: 18021
19 Correct 220 ms 708 KB # of queries: 18239
20 Correct 200 ms 432 KB # of queries: 17075
21 Correct 185 ms 440 KB # of queries: 16096
22 Correct 234 ms 712 KB # of queries: 18413
23 Correct 254 ms 704 KB # of queries: 17994
24 Correct 84 ms 600 KB # of queries: 8263
25 Correct 219 ms 592 KB # of queries: 17890
26 Correct 205 ms 848 KB # of queries: 16769
27 Correct 98 ms 344 KB # of queries: 8414
28 Correct 216 ms 448 KB # of queries: 17935
29 Correct 218 ms 344 KB # of queries: 17915
30 Correct 219 ms 468 KB # of queries: 17935