Submission #942313

# Submission time Handle Problem Language Result Execution time Memory
942313 2024-03-10T12:42:50 Z daoquanglinh2007 Toxic Gene (NOI23_toxic) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#include "toxic.h"
using namespace std;

#define isz(a) (int)(a).size()

const int NM = 300;

int p[NM+5];
char a[NM+5];

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

void determine_type(int n){
	for (int i = 1; i <= n; i++){
		a[i] = ' ';
		p[i] = i;
	}
	shuffle(p+1, p+1+n, rng);
	int cur = 0, ft = -1;
	while (cur < n){
		int l = cur+1, r = min(n, cur+8);
		vector <int> species = {};
		for (int i = cur+1; i <= r; i++)
			species.push_back(p[i]);
		if (query_sample(species) == r-cur){
			cur = r;
			continue;
		}
		r--;
		int res = r+1;
		while (l <= r){
			int mid = (l+r)/2;
			for (int i = cur+1; i <= mid; i++)
				species.push_back(p[i]);
			if (query_sample(species) < mid-cur){
				res = mid;
				r = mid-1;
			}
			else l = mid+1;
		}
		a[p[res]] = 'T';
		cur = res;
		if (ft == -1) ft = p[res];
	}
	while (true){
		vector <int> arr = {}, species = {};
		for (int i = 1; i <= n; i++){
			if (a[i] == ' ' && isz(arr) < 8) arr.push_back(i); 
		}
		if (arr.empty()) break;
		for (int i = 0; i < isz(arr); i++){
			for (int j = 0; j < (1<<i); j++) species.push_back(arr[i]);
		}
		species.push_back(ft);
		int tmp = query_sample(species);
		for (int i = 0; i < isz(arr); i++)
			if ((tmp>>i)&1) a[arr[i]] = 'S'; else a[arr[i]] = 'R';
	}
	for (int i = 1; i <= n; i++)
		answer_type(i, a[i]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -