#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]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |