Submission #110944

# Submission time Handle Problem Language Result Execution time Memory
110944 2019-05-13T09:29:26 Z Jatana Library (JOI18_library) C++17
0 / 100
579 ms 448 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include "library.h"

using namespace std;

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

int N;
vector<int> go(int x, int forb) {
	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;
			}
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (A == B) {
				r = m;
			} else {
				l = m;	
			}
		}
		{
			vector<int> Q(N, 0);
			Q[other[l]] = 1;
			int A = Query(Q);
			Q[x] = 1;
			int B = Query(Q);
			if (A != B) 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;
		}
		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 32 ms 256 KB # of queries: 3178
2 Correct 40 ms 256 KB # of queries: 3100
3 Correct 37 ms 256 KB # of queries: 3334
4 Correct 36 ms 384 KB # of queries: 3244
5 Correct 42 ms 384 KB # of queries: 3292
6 Correct 30 ms 256 KB # of queries: 3268
7 Correct 35 ms 256 KB # of queries: 3302
8 Correct 38 ms 384 KB # of queries: 3160
9 Correct 35 ms 256 KB # of queries: 3178
10 Incorrect 2 ms 384 KB Wrong Answer [4]
11 Correct 2 ms 384 KB # of queries: 0
12 Correct 3 ms 256 KB # of queries: 2
13 Correct 2 ms 256 KB # of queries: 8
14 Correct 2 ms 256 KB # of queries: 12
15 Correct 3 ms 256 KB # of queries: 104
16 Correct 5 ms 384 KB # of queries: 288
# Verdict Execution time Memory Grader output
1 Correct 32 ms 256 KB # of queries: 3178
2 Correct 40 ms 256 KB # of queries: 3100
3 Correct 37 ms 256 KB # of queries: 3334
4 Correct 36 ms 384 KB # of queries: 3244
5 Correct 42 ms 384 KB # of queries: 3292
6 Correct 30 ms 256 KB # of queries: 3268
7 Correct 35 ms 256 KB # of queries: 3302
8 Correct 38 ms 384 KB # of queries: 3160
9 Correct 35 ms 256 KB # of queries: 3178
10 Incorrect 2 ms 384 KB Wrong Answer [4]
11 Correct 2 ms 384 KB # of queries: 0
12 Correct 3 ms 256 KB # of queries: 2
13 Correct 2 ms 256 KB # of queries: 8
14 Correct 2 ms 256 KB # of queries: 12
15 Correct 3 ms 256 KB # of queries: 104
16 Correct 5 ms 384 KB # of queries: 288
17 Incorrect 3 ms 384 KB Wrong Answer [4]
18 Incorrect 579 ms 328 KB Wrong Answer [3]
19 Correct 465 ms 448 KB # of queries: 19648
20 Correct 342 ms 380 KB # of queries: 18356
21 Incorrect 2 ms 256 KB Wrong Answer [4]
22 Incorrect 3 ms 256 KB Wrong Answer [4]
23 Correct 460 ms 324 KB # of queries: 19846
24 Incorrect 2 ms 384 KB Wrong Answer [4]
25 Incorrect 2 ms 328 KB Wrong Answer [4]
26 Incorrect 3 ms 332 KB Wrong Answer [4]
27 Correct 143 ms 256 KB # of queries: 9666
28 Correct 340 ms 332 KB # of queries: 17954
29 Correct 356 ms 256 KB # of queries: 17934
30 Correct 339 ms 428 KB # of queries: 17954