Submission #994833

# Submission time Handle Problem Language Result Execution time Memory
994833 2024-06-08T07:06:00 Z NintsiChkhaidze Library (JOI18_library) C++17
19 / 100
229 ms 444 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

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);
	for(int i = 0; i < N; i++) {
		ans[i] = fix[i] = 0;
	}
	
	int l = 0,r = N - 1;
	while (l <= r){
		
		vector <int> M(N);
		for (int i = 0; i < N; i++) {
			M[i] = 1;
			if (fix[i]) M[i] = 0;
		}
		
		if (l == r){
			for (int i=0;i<N;i++){
				if (M[i]) {
					ans[l] = i;
					break;
				}
			}
			break;
		}
		
		int cnt = 0;
		for (int i = 0; i < N; i++){
			if (!M[i]) continue;
			
			M[i] = 0;
			if (Query(M) == 1){
				++cnt;
				if (cnt == 1) ans[l] = i;
				else ans[r] = i; 
				
				fix[i] = 1;
			}
			
			M[i] = 1;
		}
		
		if (l && !check(ans[l - 1],ans[l])){
			swap(ans[l],ans[r]);
		}
		
		l += 1;
		r -= 1;
	}
	
	for (int i=0;i<N;i++)
		ans[i] += 1;
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 80 ms 344 KB # of queries: 9407
2 Correct 73 ms 344 KB # of queries: 9309
3 Correct 91 ms 344 KB # of queries: 10199
4 Correct 82 ms 344 KB # of queries: 10199
5 Correct 84 ms 344 KB # of queries: 10199
6 Correct 94 ms 344 KB # of queries: 10199
7 Correct 90 ms 344 KB # of queries: 10199
8 Correct 91 ms 344 KB # of queries: 9503
9 Correct 74 ms 344 KB # of queries: 10097
10 Correct 29 ms 344 KB # of queries: 4287
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 340 KB # of queries: 69
16 Correct 3 ms 344 KB # of queries: 207
# Verdict Execution time Memory Grader output
1 Correct 80 ms 344 KB # of queries: 9407
2 Correct 73 ms 344 KB # of queries: 9309
3 Correct 91 ms 344 KB # of queries: 10199
4 Correct 82 ms 344 KB # of queries: 10199
5 Correct 84 ms 344 KB # of queries: 10199
6 Correct 94 ms 344 KB # of queries: 10199
7 Correct 90 ms 344 KB # of queries: 10199
8 Correct 91 ms 344 KB # of queries: 9503
9 Correct 74 ms 344 KB # of queries: 10097
10 Correct 29 ms 344 KB # of queries: 4287
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 3
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 340 KB # of queries: 69
16 Correct 3 ms 344 KB # of queries: 207
17 Runtime error 229 ms 444 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -