Submission #110950

# Submission time Handle Problem Language Result Execution time Memory
110950 2019-05-13T10:01:38 Z Jatana Library (JOI18_library) C++17
19 / 100
614 ms 452 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#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, int forb) {
	cout << "RUNNING" << endl;
	vector<int> p{x};
	vector<int> other;
	for (int i = 0; i < N; i++) {
		if (i != x && i != forb) 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, -1);
		if (len(p) == N) {
			for (int &x : p) x++;
			Answer(p);
			return;
		}
		cout << "p[1]" << p[1] + 1 << endl;
		vector<int> q = go(0, p[1]);
		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 39 ms 256 KB # of queries: 3178
2 Correct 38 ms 256 KB # of queries: 3100
3 Correct 48 ms 256 KB # of queries: 3334
4 Correct 39 ms 256 KB # of queries: 3244
5 Correct 38 ms 384 KB # of queries: 3292
6 Correct 36 ms 384 KB # of queries: 3268
7 Correct 41 ms 384 KB # of queries: 3302
8 Correct 29 ms 256 KB # of queries: 3160
9 Correct 60 ms 256 KB # of queries: 3178
10 Correct 41 ms 256 KB # of queries: 1982
11 Correct 2 ms 384 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 8
14 Correct 2 ms 384 KB # of queries: 12
15 Correct 4 ms 384 KB # of queries: 104
16 Correct 8 ms 256 KB # of queries: 288
# Verdict Execution time Memory Grader output
1 Correct 39 ms 256 KB # of queries: 3178
2 Correct 38 ms 256 KB # of queries: 3100
3 Correct 48 ms 256 KB # of queries: 3334
4 Correct 39 ms 256 KB # of queries: 3244
5 Correct 38 ms 384 KB # of queries: 3292
6 Correct 36 ms 384 KB # of queries: 3268
7 Correct 41 ms 384 KB # of queries: 3302
8 Correct 29 ms 256 KB # of queries: 3160
9 Correct 60 ms 256 KB # of queries: 3178
10 Correct 41 ms 256 KB # of queries: 1982
11 Correct 2 ms 384 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 8
14 Correct 2 ms 384 KB # of queries: 12
15 Correct 4 ms 384 KB # of queries: 104
16 Correct 8 ms 256 KB # of queries: 288
17 Incorrect 614 ms 452 KB Wrong Answer [3]
18 Incorrect 520 ms 424 KB Wrong Answer [3]
19 Correct 483 ms 424 KB # of queries: 19648
20 Correct 380 ms 328 KB # of queries: 18356
21 Correct 414 ms 376 KB # of queries: 17874
22 Correct 457 ms 256 KB # of queries: 19302
23 Correct 527 ms 256 KB # of queries: 19846
24 Correct 146 ms 328 KB # of queries: 9154
25 Correct 406 ms 376 KB # of queries: 19320
26 Correct 373 ms 320 KB # of queries: 18540
27 Correct 128 ms 412 KB # of queries: 9666
28 Correct 385 ms 256 KB # of queries: 17954
29 Correct 420 ms 384 KB # of queries: 17934
30 Correct 457 ms 332 KB # of queries: 17954