| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 829900 | rainboy | Toxic Gene (NOI23_toxic) | C++17 | 7 ms | 392 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "toxic.h"
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
const int S = 8;	/* 2^S <= 300 */
int min(int a, int b) { return a < b ? a : b; }
unsigned int X;
int rand_() {
	return (X *= 3) >> 1;
}
void determine_type(int n) {
	vi pp(n);
	for (int i = 0; i < n; i++)
		pp[i] = i;
	X = 12345;
	for (int i = 0; i < n; i++) {
		int j = rand_() % (i + 1), tmp;
		tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
	}
	string cc(n, '?');
	int m = (n + S - 1) / S;
	vi done(m, 0);
	for (int h = 0; h < m; h++) {
		int l = h * S, r = min((h + 1) * S, n);
		vi ii;
		for (int i = l; i < r; i++)
			for (int t = 0; t < 1 << i - l; t++)
				ii.push_back(pp[i] + 1);
		int b = query_sample(ii);
		if (b == (1 << r - l) - 1)
			continue;
		for (int i = l; i < r; i++)
			if ((b & 1 << i - l) != 0)
				cc[i] = 'S';
		int lower = l, upper = r;
		while (1) {
			while (upper - lower > 1) {
				int i_ = (lower + upper) / 2;
				ii.clear();
				for (int i = lower; i < i_; i++)
					ii.push_back(pp[i] + 1);
				if (query_sample(ii) == i_ - lower)
					lower = i_;
				else
					upper = i_;
			}
			cc[lower++] = 'T';
			upper = r;
			ii.clear();
			for (int i = lower; i < upper; i++)
				ii.push_back(pp[i] + 1);
			if (ii.size() == 0 || query_sample(ii) == upper - lower)
				break;
		}
		for (int i = l; i < r; i++)
			if (cc[i] == '?')
				cc[i] = 'R';
	}
	int t = 0;
	while (cc[t] != 'T')
		t++;
	for (int h = 0; h < m; h++) {
		int l = h * S, r = min((h + 1) * S, n);
		if (cc[l] != '?')
			continue;
		vi ii;
		ii.push_back(pp[t] + 1);
		for (int i = l; i < r; i++)
			for (int t = 0; t < 1 << i - l; t++)
				ii.push_back(pp[i] + 1);
		int b = query_sample(ii);
		for (int i = l; i < r; i++)
			cc[i] = (b & 1 << i - l) != 0 ? 'S' : 'R';
	}
	for (int i = 0; i < n; i++)
		answer_type(pp[i] + 1, cc[i]);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
