Submission #908400

# Submission time Handle Problem Language Result Execution time Memory
908400 2024-01-16T11:48:37 Z penguin133 Library (JOI18_library) C++17
100 / 100
193 ms 676 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
 
void Solve(int N){
  if(N == 2){Answer({1, 2}); return;}
  if(N == 1){Answer({1}); return;}
	int A[N+1];
	for(int i=1;i<=N;i++)A[i] = 0;
	vector<int>v;
	for(int i=1;i<=N;i++)v.push_back(1);
	vector<int>fin;
	for(int i=1;i<=N;i++){
		v[i-1] = 0;
		int ans = Query(v);
		if(ans == 1){fin.push_back(i), A[i] = 1; break;}
		v[i-1] = 1;
	}
	for(int i=2;i<=N;i++){
		int x = fin.back();
		v.clear();
		for(int k=0;k<N;k++)v.push_back(0);
		v[x-1] = 1;
		int lo = 1, hi = N;
		while(lo < hi){
			int mid = (lo + hi) >> 1;
			for(int i=0;i<N;i++)v[i] = 0;
			int cnt = 0;
			for(int j = lo; j <= mid; j++){
				if(A[j])continue;
				v[j - 1] = 1;
				cnt++;
			}
			if(cnt == 0){
				lo = mid + 1;
				continue;
			}
			v[x-1] = 1;
			int tmp = Query(v);
			v[x-1] = 0;
			int tmp2 = Query(v);
			//cout << lo << ' ' << mid << ' ' << tmp << ' ' << tmp2 << '\n';
			if(tmp > tmp2)lo = mid + 1;
			else hi = mid;
		}
		//cout << lo << ' ';
		fin.push_back(lo);
		A[lo] = 1;
	}
	Answer(fin);
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 344 KB # of queries: 2749
2 Correct 22 ms 344 KB # of queries: 2787
3 Correct 24 ms 344 KB # of queries: 3004
4 Correct 19 ms 596 KB # of queries: 2921
5 Correct 18 ms 344 KB # of queries: 2868
6 Correct 28 ms 344 KB # of queries: 2919
7 Correct 25 ms 344 KB # of queries: 2908
8 Correct 18 ms 344 KB # of queries: 2742
9 Correct 21 ms 344 KB # of queries: 2880
10 Correct 11 ms 344 KB # of queries: 1628
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 0
13 Correct 0 ms 344 KB # of queries: 6
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 91
16 Correct 2 ms 344 KB # of queries: 231
# Verdict Execution time Memory Grader output
1 Correct 23 ms 344 KB # of queries: 2749
2 Correct 22 ms 344 KB # of queries: 2787
3 Correct 24 ms 344 KB # of queries: 3004
4 Correct 19 ms 596 KB # of queries: 2921
5 Correct 18 ms 344 KB # of queries: 2868
6 Correct 28 ms 344 KB # of queries: 2919
7 Correct 25 ms 344 KB # of queries: 2908
8 Correct 18 ms 344 KB # of queries: 2742
9 Correct 21 ms 344 KB # of queries: 2880
10 Correct 11 ms 344 KB # of queries: 1628
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 0
13 Correct 0 ms 344 KB # of queries: 6
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 91
16 Correct 2 ms 344 KB # of queries: 231
17 Correct 188 ms 428 KB # of queries: 19548
18 Correct 164 ms 420 KB # of queries: 18781
19 Correct 193 ms 424 KB # of queries: 18931
20 Correct 157 ms 596 KB # of queries: 17933
21 Correct 155 ms 428 KB # of queries: 16904
22 Correct 173 ms 424 KB # of queries: 19157
23 Correct 179 ms 676 KB # of queries: 18738
24 Correct 65 ms 420 KB # of queries: 8615
25 Correct 188 ms 424 KB # of queries: 18634
26 Correct 161 ms 672 KB # of queries: 17475
27 Correct 75 ms 416 KB # of queries: 8856
28 Correct 96 ms 424 KB # of queries: 10069
29 Correct 106 ms 420 KB # of queries: 10063
30 Correct 98 ms 420 KB # of queries: 10069