Submission #654359

# Submission time Handle Problem Language Result Execution time Memory
654359 2022-10-31T07:42:17 Z SanguineChameleon Library (JOI18_library) C++14
0 / 100
48 ms 464 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n) {
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		a[i] = 1;
	}
	int px = -1;
	for (int i = 0; i < n; i++) {
		a[i] = 0;
		if (Query(a) == 1) {
			px = i + 1;
		}
		a[i] = 1;
	}
	vector<int> res(n);
	res[0] = px;
	vector<int> p(n);
	iota(p.begin(), p.end(), 1);
	p.erase(find(p.begin(), p.end(), px));
	for (int i = 1; i < n; i++) {
		int lt = 0;
		int rt = (int)p.size() - 1;
		int pt = -1;
		while (lt <= rt) {
			int mt = (lt + rt) / 2;
			fill(a.begin(), a.end(), 0);
			for (int j = 0; j <= mt; j++) {
				a[p[j] - 1] = 1;
			}
			int d1 = Query(a);
			a[px - 1] = 1;
			int d2 = Query(a);
			if (d1 == d2) {
				pt = mt;
				rt = mt - 1;
			}
			else {
				lt = mt + 1;
			}
		}
		res[i] = (px = p[pt]);
		p.erase(find(p.begin(), p.end(), px));
	}
	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 208 KB # of queries: 2586
2 Correct 24 ms 296 KB # of queries: 2555
3 Correct 46 ms 208 KB # of queries: 2716
4 Correct 43 ms 208 KB # of queries: 2728
5 Correct 38 ms 376 KB # of queries: 2714
6 Correct 45 ms 300 KB # of queries: 2712
7 Correct 26 ms 308 KB # of queries: 2718
8 Correct 40 ms 208 KB # of queries: 2611
9 Correct 48 ms 304 KB # of queries: 2713
10 Correct 25 ms 208 KB # of queries: 1597
11 Runtime error 1 ms 464 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 208 KB # of queries: 2586
2 Correct 24 ms 296 KB # of queries: 2555
3 Correct 46 ms 208 KB # of queries: 2716
4 Correct 43 ms 208 KB # of queries: 2728
5 Correct 38 ms 376 KB # of queries: 2714
6 Correct 45 ms 300 KB # of queries: 2712
7 Correct 26 ms 308 KB # of queries: 2718
8 Correct 40 ms 208 KB # of queries: 2611
9 Correct 48 ms 304 KB # of queries: 2713
10 Correct 25 ms 208 KB # of queries: 1597
11 Runtime error 1 ms 464 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -