Submission #831511

# Submission time Handle Problem Language Result Execution time Memory
831511 2023-08-20T10:02:02 Z MadokaMagicaFan Library (JOI18_library) C++14
0 / 100
0 ms 292 KB
#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#define pb push_back
#define sz(v) ((int)v.size())

mt19937 rng(time(NULL));

vector<int> ans;

bitset<1001> in;

int query(int s, vector<int> &z) {
	shuffle(z.begin(), z.end(), rng);
	if (sz(z) == 1) return z[0];
	if (sz(z) == 0) return -1;
	int l = 0;
	int r = sz(z) - 1;
	int c1, c2;

	vector<int> j;

	while (l < r) {
		int m = (l+r)/2;
		j.clear();
		for (int i = l; i <= m; ++i)
			j.pb(z[i]);
		c1 = Query(j);
		j.pb(s);
		c2 = Query(j);
		if (c1 >= c2)
			r = m;
		else
			l = m+1;
	}

	if (l == sz(z) -1) {
		j.clear(); j.pb(s); j.pb(z.back());
		if (Query(j) != 1)
			return -1;
	}

	return z[l];
}

void remain(vector<int> &u, int n) {
	u.clear();
	for (int i = 1; i <= n; ++i)
		if (!in[i]) u.pb(i);
}

void Solve(int n) {
	int c = 1;
	vector<int> u;

	while (c != -1) {
		in[c] = 1;
		ans.pb(c);
		remain(u, n);
		c = query(c, u);
	}

	reverse(ans.begin(), ans.end());
	c = ans.back();
	ans.pop_back();
	while (c != -1) {
		in[c] = 1;
		ans.pb(c);
		remain(u, n);
		c = query(c, u);
	}

	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 292 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 292 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -