#include "toxic.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fr first
#define se second
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
void determine_type(int n) {
vector<int> toxics;
for (int i = 1; i <= n; i += 3) {
vector<int> batch;
for (int j = i; j < (i + 3); j++) batch.push_back(j);
if (query_sample(batch) != ((int) batch.size())) {
for (int j = i; j < (i + 3); j++) {
if (query_sample({j}) == 0) toxics.push_back(j);
}
}
}
vector<int> tx(301);
for (auto u : toxics) {
tx[u] = 1;
answer_type(u, 'T');
}
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 = {toxics[0]};
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 time | Memory | Grader output |
---|
Fetching results... |