#include<bits/stdc++.h>
#include"toxic.h"
using namespace std;
int query_sample(vector<int> species);
void determine_type(int n){
int l = 1, r = n;
vector<int> vec(n);
vector<bool> done(n+1, 0);
iota(vec.begin(), vec.end(), 1);
while(l < r){
int mid = (l+r)>>1;
int tmp = query_sample(vector<int>(vec.begin() + l - 1, vec.begin() + mid));
if(tmp != mid - l + 1)r = mid;
else l = mid+1;
}
vec.erase(vec.begin() + l - 1);
answer_type(l, 'T');
int d = 0;
vector<int> sampling;
vector<int> species;
for(int i = 0; i < vec.size(); i++){
if(species.size() + (1<<d) < 300){
for(int _ = 0; _ < (1<<d); _++)species.push_back(vec[i]);
sampling.push_back(vec[i]);
d++;
}
else {
int tot1 = query_sample(species);
if(tot1 == species.size()){
species.push_back(l);
int tot2 = query_sample(species);
for(int j = 0; j < sampling.size(); j++){
if(tot2&(1<<j)){
answer_type(sampling[j], 'S');
done[sampling[j]] = 1;
}
else answer_type(sampling[j], 'R');
}
}
else {
// cout << tot1 << " " << tot2 << endl;
for(int j = 0; j < sampling.size(); j++){
if(tot1&(1<<j)){
answer_type(sampling[j], 'S');
done[sampling[j]] = 1;
}
else {
if(query_sample({sampling[j]}))answer_type(sampling[j], 'R');
else answer_type(sampling[j], 'T');
}
}
}
sampling = {vec[i]};
species = {vec[i]};
d = 1;
}
}
int tot1 = query_sample(species);
if(tot1 == species.size()){
species.push_back(l);
int tot2 = query_sample(species);
for(int j = 0; j < sampling.size(); j++){
if(tot2&(1<<j)){
answer_type(sampling[j], 'S');
done[sampling[j]] = 1;
}
else answer_type(sampling[j], 'R');
}
}
else {
// cout << tot1 << " " << tot2 << endl;
for(int j = 0; j < sampling.size(); j++){
if(tot1&(1<<j)){
answer_type(sampling[j], 'S');
done[sampling[j]] = 1;
}
else {
if(query_sample({sampling[j]}))answer_type(sampling[j], 'R');
else answer_type(sampling[j], 'T');
}
}
}
}
Compilation message
toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < vec.size(); i++){
| ~~^~~~~~~~~~~~
toxic.cpp:31:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(tot1 == species.size()){
| ~~~~~^~~~~~~~~~~~~~~~~
toxic.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j = 0; j < sampling.size(); j++){
| ~~^~~~~~~~~~~~~~~~~
toxic.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int j = 0; j < sampling.size(); j++){
| ~~^~~~~~~~~~~~~~~~~
toxic.cpp:61:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | if(tot1 == species.size()){
| ~~~~~^~~~~~~~~~~~~~~~~
toxic.cpp:64:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int j = 0; j < sampling.size(); j++){
| ~~^~~~~~~~~~~~~~~~~
toxic.cpp:74:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(int j = 0; j < sampling.size(); j++){
| ~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Partially correct |
4 ms |
344 KB |
Partially correct |
3 |
Partially correct |
4 ms |
348 KB |
Partially correct |
4 |
Partially correct |
4 ms |
348 KB |
Partially correct |
5 |
Partially correct |
4 ms |
348 KB |
Partially correct |
6 |
Partially correct |
4 ms |
348 KB |
Partially correct |
7 |
Partially correct |
4 ms |
344 KB |
Partially correct |
8 |
Partially correct |
4 ms |
348 KB |
Partially correct |
9 |
Partially correct |
4 ms |
348 KB |
Partially correct |
10 |
Partially correct |
6 ms |
500 KB |
Partially correct |
11 |
Partially correct |
4 ms |
348 KB |
Partially correct |
12 |
Partially correct |
4 ms |
348 KB |
Partially correct |
13 |
Partially correct |
4 ms |
348 KB |
Partially correct |
14 |
Partially correct |
4 ms |
348 KB |
Partially correct |
15 |
Partially correct |
4 ms |
348 KB |
Partially correct |
16 |
Partially correct |
4 ms |
348 KB |
Partially correct |
17 |
Partially correct |
4 ms |
500 KB |
Partially correct |
18 |
Partially correct |
4 ms |
348 KB |
Partially correct |
19 |
Partially correct |
6 ms |
348 KB |
Partially correct |
20 |
Partially correct |
6 ms |
348 KB |
Partially correct |
21 |
Partially correct |
6 ms |
496 KB |
Partially correct |
22 |
Correct |
4 ms |
348 KB |
Output is correct |
23 |
Correct |
3 ms |
348 KB |
Output is correct |
24 |
Correct |
4 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
26 |
Correct |
4 ms |
348 KB |
Output is correct |
27 |
Correct |
4 ms |
348 KB |
Output is correct |
28 |
Correct |
4 ms |
496 KB |
Output is correct |
29 |
Correct |
4 ms |
348 KB |
Output is correct |
30 |
Correct |
4 ms |
348 KB |
Output is correct |
31 |
Correct |
4 ms |
348 KB |
Output is correct |
32 |
Correct |
4 ms |
348 KB |
Output is correct |
33 |
Correct |
4 ms |
348 KB |
Output is correct |
34 |
Partially correct |
4 ms |
344 KB |
Partially correct |
35 |
Partially correct |
4 ms |
348 KB |
Partially correct |
36 |
Partially correct |
1 ms |
348 KB |
Partially correct |