Submission #110951

# Submission time Handle Problem Language Result Execution time Memory
110951 2019-05-13T10:04:15 Z Jatana Library (JOI18_library) C++17
100 / 100
501 ms 456 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include "library.h"

#define cout if (0) cout

using namespace std;

#define pb push_back
#define len(v) ((int)v.size())

int N;
vector<int> go(int x, set<int> forb) {
	cout << "RUNNING" << endl;
	vector<int> p{x};
	vector<int> other;
	for (int i = 0; i < N; i++) {
		if (i != x && !forb.count(i)) other.pb(i);
	}
	while (!other.empty()) {
		int l = 0;
		int r = len(other);
		while (r - l > 1) {
			int m = (l + r) / 2;
			vector<int> Q(N, 0);
			for (int j = l; j < m; j++) {
				Q[other[j]] = 1;
				cout << other[j] + 1 << " ";
			}
			cout << endl;
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (B <= A) {
				cout << "GOOOD" << endl;
				r = m;
			} else {
				cout << "BAD" << endl;
				l = m;
			}
		}
		cout << other[l] << endl;
		{
			vector<int> Q(N, 0);
			Q[other[l]] = 1;
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (B > A) return p;
		}
		p.pb(other[l]);
		other.erase(other.begin() + l);
		x = p.back();
	}
	return p;
}

void Solve(int _N) {
	N = _N;
	{
		vector<int> p = go(0, set<int>());
		if (len(p) == N) {
			for (int &x : p) x++;
			Answer(p);
			return;
		}
		cout << "p[1]" << p[1] + 1 << endl;
		vector<int> q = go(0, set<int>(p.begin() + 1, p.end()));
		reverse(q.begin(), q.end());
		q.pop_back();
		// reverse(p.begin(), p.end());
		for (int x : p) {
			q.pb(x);
		}
		swap(p, q);
		for (int &x : p) x++;
		for (int x : p) {
			cout << x << " ";
		}
		cout << endl;
		Answer(p);
		return;
	}

	// vector<int> M(N);

	// for(int i = 0; i < N; i++) {
	// 	M[i] = 1;
	// }

	// int A = Query(M);

	// vector<int> res(N);

	// for(int i = 0; i < N; i++) {
	// 	res[i] = i + 1;
	// }

	// Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 43 ms 256 KB # of queries: 2778
2 Correct 53 ms 256 KB # of queries: 2782
3 Correct 37 ms 316 KB # of queries: 2926
4 Correct 41 ms 256 KB # of queries: 2924
5 Correct 34 ms 316 KB # of queries: 2908
6 Correct 41 ms 316 KB # of queries: 2914
7 Correct 35 ms 316 KB # of queries: 2916
8 Correct 33 ms 384 KB # of queries: 2804
9 Correct 60 ms 384 KB # of queries: 2908
10 Correct 25 ms 316 KB # of queries: 1730
11 Correct 2 ms 256 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 8
14 Correct 3 ms 384 KB # of queries: 12
15 Correct 3 ms 384 KB # of queries: 104
16 Correct 5 ms 256 KB # of queries: 240
# Verdict Execution time Memory Grader output
1 Correct 43 ms 256 KB # of queries: 2778
2 Correct 53 ms 256 KB # of queries: 2782
3 Correct 37 ms 316 KB # of queries: 2926
4 Correct 41 ms 256 KB # of queries: 2924
5 Correct 34 ms 316 KB # of queries: 2908
6 Correct 41 ms 316 KB # of queries: 2914
7 Correct 35 ms 316 KB # of queries: 2916
8 Correct 33 ms 384 KB # of queries: 2804
9 Correct 60 ms 384 KB # of queries: 2908
10 Correct 25 ms 316 KB # of queries: 1730
11 Correct 2 ms 256 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 8
14 Correct 3 ms 384 KB # of queries: 12
15 Correct 3 ms 384 KB # of queries: 104
16 Correct 5 ms 256 KB # of queries: 240
17 Correct 423 ms 456 KB # of queries: 19170
18 Correct 474 ms 380 KB # of queries: 18968
19 Correct 501 ms 332 KB # of queries: 19148
20 Correct 456 ms 448 KB # of queries: 17888
21 Correct 469 ms 328 KB # of queries: 16824
22 Correct 389 ms 328 KB # of queries: 19212
23 Correct 350 ms 420 KB # of queries: 19146
24 Correct 124 ms 424 KB # of queries: 8882
25 Correct 374 ms 320 KB # of queries: 18718
26 Correct 364 ms 380 KB # of queries: 17454
27 Correct 177 ms 432 KB # of queries: 8798
28 Correct 476 ms 384 KB # of queries: 17954
29 Correct 359 ms 384 KB # of queries: 17934
30 Correct 396 ms 256 KB # of queries: 17954