Submission #950952

# Submission time Handle Problem Language Result Execution time Memory
950952 2024-03-21T03:07:08 Z qwe1rt1yuiop1 Toxic Gene (NOI23_toxic) C++17
0 / 100
10 ms 604 KB
#include "toxic.h"
using namespace std;
#include <bits/stdc++.h>
#define sz(x) (int)x.size()

vector<int> v;
string ans;

int n0;

void ac(int x, char c)
{
	assert(ans[x] == '0');
	x = n0 - x + 1;
	answer_type(x, c);
	x = n0 - x + 1;
	ans[x] = c;
}

int qry()
{
	for (int &i : v)
		i = n0 - i + 1;
	int ret = query_sample(v);
	for (int &i : v)
		i = n0 - i + 1;
	return ret;
}

int cnt1 = 0, cnt2 = 0;

int qry1(int l, int r)
{
	++cnt1;
	v.clear();
	for (int i = l; i <= r; ++i)
		v.emplace_back(i);
	return qry();
}

void qry2()
{
	++cnt2;
	int cnt = sz(v) - 1;
	for (int i = 0; i < cnt; ++i)
		for (int j = 0; j < ((1 << i) - 1); ++j)
			v.emplace_back(v[i]);

	int tmp = sz(v);
	assert(tmp == (tmp & (-tmp)));

	int ret = qry();
	// --ret;

	for (int i = 0; i < cnt; ++i)
		if (ret >> i & 1)
			ac(v[i], 'S');
		else
			ac(v[i], 'R');
}

void determine_type(int n)
{
	cnt1 = cnt2 = 0;
	n0 = n;
	ans.assign(n + 1, '0');
	vector<int> t;
	t.emplace_back(0);
	while (1)
	{
		int l = t.back() + 2, r = n + 2;
		if (l > r)
			break;
		while (l < r)
		{
			int mid = (l + r) >> 1;
			if (qry1(t.back() + 1, mid - 1) == (mid - 1) - (t.back() + 1) + 1)
				l = mid + 1;
			else
				r = mid;
		}
		if (l - 1 > n)
			break;
		t.emplace_back(l - 1);
		ac(l - 1, 'T');
		/*
			int l = t.back() + 1, r = n;
			if (l > r || qry1(l, r) == r - l + 1)
				break;
			while (l < r)
			{
				int mid = (l + r) >> 1;
				if (qry1(l, mid) == mid - l + 1)
					l = mid + 1;
				else
					r = mid;
			}
			t.emplace_back(l);
			ac(l, 'T');
		*/
	}

	/*
		for (int i = 1; i <= n; ++i)
			if (ans[i] == '0')
			{
				v.clear();
				v.emplace_back(t.back());
				v.emplace_back(i);
				if (qry() == 1)
					ac(i, 'S');
				else
					ac(i, 'R');
			}
	*/

	vector<int> r;
	for (int i = 1; i <= n; ++i)
		if (ans[i] == '0')
			r.emplace_back(i);

	while (!r.empty())
	{
		v.clear();
		while (!r.empty() && sz(v) < 8)
			v.emplace_back(r.back()), r.pop_back();
		v.emplace_back(t.back());
		qry2();
	}
	assert(cnt2 <= 40);
	assert(cnt1 <= 250);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Partially correct 6 ms 524 KB Partially correct
3 Partially correct 8 ms 348 KB Partially correct
4 Partially correct 7 ms 348 KB Partially correct
5 Partially correct 6 ms 348 KB Partially correct
6 Partially correct 7 ms 348 KB Partially correct
7 Partially correct 7 ms 348 KB Partially correct
8 Partially correct 7 ms 524 KB Partially correct
9 Partially correct 7 ms 348 KB Partially correct
10 Partially correct 8 ms 528 KB Partially correct
11 Partially correct 8 ms 348 KB Partially correct
12 Partially correct 7 ms 348 KB Partially correct
13 Partially correct 7 ms 512 KB Partially correct
14 Partially correct 9 ms 344 KB Partially correct
15 Partially correct 8 ms 348 KB Partially correct
16 Partially correct 8 ms 348 KB Partially correct
17 Partially correct 8 ms 344 KB Partially correct
18 Partially correct 8 ms 348 KB Partially correct
19 Partially correct 9 ms 348 KB Partially correct
20 Partially correct 9 ms 344 KB Partially correct
21 Partially correct 10 ms 344 KB Partially correct
22 Partially correct 7 ms 348 KB Partially correct
23 Partially correct 7 ms 348 KB Partially correct
24 Partially correct 6 ms 528 KB Partially correct
25 Partially correct 6 ms 600 KB Partially correct
26 Partially correct 6 ms 348 KB Partially correct
27 Partially correct 7 ms 348 KB Partially correct
28 Runtime error 2 ms 604 KB Execution killed with signal 6
29 Halted 0 ms 0 KB -