Submission #1079933

# Submission time Handle Problem Language Result Execution time Memory
1079933 2024-08-29T03:38:34 Z vjudge1 Library (JOI18_library) C++17
100 / 100
223 ms 600 KB
#include "library.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;

void Solve(int n)
{
	if (n == 1) {
		Answer({1});
		return;
	}
	if (n == 2) {
		Answer({1, 2});
		return;
	}

	int st = -1;
	vector<int> vis(n, 1);
	for (int i = 0; i < n; ++i) {
		vis[i] = false;
		if (Query(vis) == 1) {
			st = i;
			break;
		}
		vis[i] = true;
	}
	vector<int> res = {st + 1};

	vector<int> left;
	for (int i = 0; i < n; ++i) if (i != st) left.emplace_back(i);

	for (int i = 1; i < n; ++i) {
		int l = 0, r = isz(left);
		while (l + 1 < r) {
			int mid = (l + r) >> 1;
			int comp1, comp2;
			vis.assign(n, 0);
			for (int j = l; j < mid; ++j) vis[left[j]] = true;
			comp1 = Query(vis); vis[st] = true; comp2 = Query(vis);
			if (comp1 == comp2) r = mid;
			else l = mid;
		}
		int nst = left[l];
		st = nst; res.emplace_back(st + 1);
		left.erase(left.begin() + l);
	}

	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB # of queries: 2375
2 Correct 13 ms 344 KB # of queries: 2409
3 Correct 16 ms 344 KB # of queries: 2648
4 Correct 27 ms 344 KB # of queries: 2595
5 Correct 22 ms 344 KB # of queries: 2508
6 Correct 27 ms 344 KB # of queries: 2551
7 Correct 28 ms 344 KB # of queries: 2544
8 Correct 26 ms 344 KB # of queries: 2420
9 Correct 23 ms 344 KB # of queries: 2546
10 Correct 16 ms 432 KB # of queries: 1474
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: 4
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 77
16 Correct 2 ms 344 KB # of queries: 183
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB # of queries: 2375
2 Correct 13 ms 344 KB # of queries: 2409
3 Correct 16 ms 344 KB # of queries: 2648
4 Correct 27 ms 344 KB # of queries: 2595
5 Correct 22 ms 344 KB # of queries: 2508
6 Correct 27 ms 344 KB # of queries: 2551
7 Correct 28 ms 344 KB # of queries: 2544
8 Correct 26 ms 344 KB # of queries: 2420
9 Correct 23 ms 344 KB # of queries: 2546
10 Correct 16 ms 432 KB # of queries: 1474
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: 4
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 77
16 Correct 2 ms 344 KB # of queries: 183
17 Correct 190 ms 432 KB # of queries: 17982
18 Correct 197 ms 600 KB # of queries: 17293
19 Correct 195 ms 420 KB # of queries: 17467
20 Correct 176 ms 424 KB # of queries: 16325
21 Correct 176 ms 424 KB # of queries: 15324
22 Correct 206 ms 424 KB # of queries: 17669
23 Correct 205 ms 420 KB # of queries: 17224
24 Correct 79 ms 420 KB # of queries: 7915
25 Correct 223 ms 420 KB # of queries: 17136
26 Correct 162 ms 592 KB # of queries: 15963
27 Correct 78 ms 344 KB # of queries: 8040
28 Correct 182 ms 592 KB # of queries: 15957
29 Correct 172 ms 424 KB # of queries: 15939
30 Correct 172 ms 424 KB # of queries: 15957