Submission #1272814

#TimeUsernameProblemLanguageResultExecution timeMemory
1272814ortsacToxic Gene (NOI23_toxic)C++17
0 / 100
0 ms332 KiB
#include "toxic.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

void determine_type(int n) {
	vector<int> tx(301);
	vector<int> ord;
	for (int i = 1; i <= n; i++) ord.push_back(i);
	shuffle(ord.begin(), ord.end(), rng);
	int qT = 0;
	for (int i = 0; i < n; i += 3) {
		if (query_sample({ord[i], ord[i + 1], ord[i + 2]}) != 3) {
			int cnt = 0;
			for (int j = i; j <= (i + 2); j++) {
				if (((j == (i + 2)) && (cnt == 0)) || (query_sample({ord[j]}) == 0)) {
					tx[ord[j]] = 1;
					qT = ord[j];
					answer_type(ord[j], 'T');
					cnt++;
				}
			}
		}
	}
	assert(qT != 0);
	vector<int> test;
	for (int i = 1; i <= n; i++) {
		if (!tx[i]) test.push_back(i);
	}
	while (!test.empty()) {
		vector<int> curr;
		while (!test.empty() && (((int) curr.size()) < 8)) {
			curr.push_back(test.back());
			test.pop_back();
		}
		vector<int> batch = {qT};
		for (int i = 0; i < ((int) curr.size()); i++) {
			int qtd = (1 << i);
			while (qtd--) batch.push_back(curr[i]);
		}
		int r = query_sample(batch);
		for (int i = 0; i < ((int) curr.size()); i++) {
			if (r & (1 << i)) {
				answer_type(curr[i], 'S');
			} else {
				answer_type(curr[i], 'R');
			}
		}
	}
	return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...