Submission #936024

# Submission time Handle Problem Language Result Execution time Memory
936024 2024-03-01T02:04:20 Z yhkhoo Library (JOI18_library) C++17
100 / 100
197 ms 448 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N){
	if(N == 1){
		Answer({1});
		return;
	}
	vector<int> res(N);
	vector<int> m0(N, 1);
	int le=-1, re=-1;
	for(int i=0; i<N; i++){
		if(i != 0){
			m0[i-1] = 1;
		}
		m0[i] = 0;
		if(Query(m0) == 1){
			if(le == -1){
				le = i;
			}
			else{
				re = i;
			}
		}
	}
	vector<int> cons(N);
	for(int i=0; i<N; i++){
		cons[i] = i;
	}
	cons.erase(lower_bound(cons.begin(), cons.end(), le));
	cons.erase(lower_bound(cons.begin(), cons.end(), re));
	res[0] = le;
	res[N-1] = re;
	for(int i=1; i<N-1; i++){
		int l = 0, r = cons.size()-1, m;
		while(l < r){
			m = (l+r)/2;
			vector<int> m1(N, 0);
			for(int i=l; i<=m; i++){
				m1[cons[i]] = 1;
			}
			m1[res[i-1]] = 1;
			auto wit = Query(m1);
			m1[res[i-1]] = 0;
			auto wito = Query(m1);
			if(wito == wit){ // is in
				r = m;
			}
			else{ // not in
				l = m+1;
			}
		}
		res[i] = cons[l];
		cons.erase(cons.begin()+l);
	}
	for(int i=0; i<N; i++){
		res[i]++;
	}
	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 432 KB # of queries: 2540
2 Correct 21 ms 436 KB # of queries: 2533
3 Correct 23 ms 432 KB # of queries: 2678
4 Correct 17 ms 436 KB # of queries: 2680
5 Correct 21 ms 436 KB # of queries: 2678
6 Correct 21 ms 428 KB # of queries: 2670
7 Correct 25 ms 440 KB # of queries: 2694
8 Correct 21 ms 436 KB # of queries: 2551
9 Correct 18 ms 436 KB # of queries: 2653
10 Correct 9 ms 436 KB # of queries: 1563
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: 6
15 Correct 1 ms 344 KB # of queries: 81
16 Correct 1 ms 344 KB # of queries: 197
# Verdict Execution time Memory Grader output
1 Correct 22 ms 432 KB # of queries: 2540
2 Correct 21 ms 436 KB # of queries: 2533
3 Correct 23 ms 432 KB # of queries: 2678
4 Correct 17 ms 436 KB # of queries: 2680
5 Correct 21 ms 436 KB # of queries: 2678
6 Correct 21 ms 428 KB # of queries: 2670
7 Correct 25 ms 440 KB # of queries: 2694
8 Correct 21 ms 436 KB # of queries: 2551
9 Correct 18 ms 436 KB # of queries: 2653
10 Correct 9 ms 436 KB # of queries: 1563
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: 6
15 Correct 1 ms 344 KB # of queries: 81
16 Correct 1 ms 344 KB # of queries: 197
17 Correct 177 ms 440 KB # of queries: 18090
18 Correct 187 ms 440 KB # of queries: 17867
19 Correct 197 ms 432 KB # of queries: 18124
20 Correct 161 ms 344 KB # of queries: 16904
21 Correct 153 ms 440 KB # of queries: 15939
22 Correct 182 ms 444 KB # of queries: 18134
23 Correct 176 ms 444 KB # of queries: 18099
24 Correct 78 ms 440 KB # of queries: 8293
25 Correct 184 ms 440 KB # of queries: 17677
26 Correct 158 ms 416 KB # of queries: 16525
27 Correct 69 ms 440 KB # of queries: 8235
28 Correct 179 ms 448 KB # of queries: 18914
29 Correct 187 ms 344 KB # of queries: 18893
30 Correct 184 ms 344 KB # of queries: 18914