Submission #994943

# Submission time Handle Problem Language Result Execution time Memory
994943 2024-06-08T08:43:33 Z NintsiChkhaidze Library (JOI18_library) C++17
19 / 100
263 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;
 
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;
	}
	
	int cnt = 0,tot = N;
	while (tot > 0){
		int k;
		while (1){
			k = rnd(N);
			if (del[k]) continue;
			break;
		}	
		
		tot -= 1;
		del[k] = 1;
	
		vector <int> M(N);
		for (int i=0;i<N;i++)
			M[i] = 1;
		M[k] = 0;
		
		int A = 1;
		if (N > 1) A = Query(M);
		if (A == 1) {
			fix[k] = 1;
			ans[0] = k;
			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,sul = 0;
			for (int w = 0; w < N; w++){
				M[w] = 0;
				if (fix[w]) M[w] = 0;
				else {
					++sul;
					int bt = ((w >> j) & 1);
					if (bt) M[w] = 1,++ones;
				}
			}
			
			if (ones == 0) continue;
			M[ans[i]] = 1;
		
			int A = Query(M);
			
			M[ans[i]] = 0;
			int B = 0;
			if (ones > 1 && ones < sul) B = Query(M);
			else B = 1;
			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);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:23:6: warning: unused variable 'cnt' [-Wunused-variable]
   23 |  int cnt = 0,tot = N;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 27 ms 344 KB # of queries: 3054
2 Correct 49 ms 596 KB # of queries: 3059
3 Correct 26 ms 344 KB # of queries: 3243
4 Correct 30 ms 344 KB # of queries: 3208
5 Correct 20 ms 340 KB # of queries: 3275
6 Correct 33 ms 344 KB # of queries: 3245
7 Correct 32 ms 344 KB # of queries: 3177
8 Correct 32 ms 344 KB # of queries: 3196
9 Correct 33 ms 344 KB # of queries: 3270
10 Correct 16 ms 344 KB # of queries: 1925
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 1 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 1 ms 344 KB # of queries: 10
15 Correct 2 ms 344 KB # of queries: 100
16 Correct 2 ms 344 KB # of queries: 242
# Verdict Execution time Memory Grader output
1 Correct 27 ms 344 KB # of queries: 3054
2 Correct 49 ms 596 KB # of queries: 3059
3 Correct 26 ms 344 KB # of queries: 3243
4 Correct 30 ms 344 KB # of queries: 3208
5 Correct 20 ms 340 KB # of queries: 3275
6 Correct 33 ms 344 KB # of queries: 3245
7 Correct 32 ms 344 KB # of queries: 3177
8 Correct 32 ms 344 KB # of queries: 3196
9 Correct 33 ms 344 KB # of queries: 3270
10 Correct 16 ms 344 KB # of queries: 1925
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 1 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 1 ms 344 KB # of queries: 10
15 Correct 2 ms 344 KB # of queries: 100
16 Correct 2 ms 344 KB # of queries: 242
17 Runtime error 263 ms 432 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -