#include "toxic.h"
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(69420);
vector<int> toxic;
void reset(){
toxic.clear();
}
void add(int x,int cnt){
for(int i=0;i<cnt;i++) toxic.push_back(x);
}
int ask(){
return query_sample(toxic);
}
void determine_type(int n){
vector<int> p(n);
vector<char> c(n+1);
iota(p.begin(),p.end(),1);
vector<int> all;
int T=0;
while(!p.empty()){
shuffle(p.begin(),p.end(),rng);
vector<int> cur;
for(int i=0;i<8;i++){
if(p.empty()) break;
cur.push_back(p.back());
p.pop_back();
}
reset();
int sz=(int)cur.size();
for(int i=0;i<sz;i++) add(cur[i],(1<<i));
int total=ask();
if(total==(1<<sz)-1) all.insert(all.end(),cur.begin(),cur.end());
else{
for(int i=sz-1;i>=0;i--){
if((total>>i)&1){
c[cur[i]]='S';
cur.erase(cur.begin()+i);
}
}
sz=(int)cur.size();
int l=0,r=sz-2,pos=sz-1;
while(l<=r){
int mid=(l+r)>>1;reset();
for(int i=0;i<=mid;i++) add(cur[i],1);
int cnt=ask();
if(cnt==0) pos=mid,r=mid-1;
else l=mid+1;
}
T=cur[pos];
c[cur[pos]]='T';
cur.erase(cur.begin()+pos);
for(int i=pos-1;i>=0;i--){
c[cur[i]]='R';
cur.erase(cur.begin()+i);
}
p.insert(p.begin(),cur.begin(),cur.end());
}
}
while(!all.empty()){
vector<int> cur;
for(int i=0;i<8;i++){
if(all.empty()) break;
cur.push_back(all.back());
all.pop_back();
}
reset();
add(T,1);
int sz=(int)cur.size();
for(int i=0;i<sz;i++) add(cur[i],(1<<i));
int total=ask();
for(int i=sz-1;i>=0;i--){
if(total>>i&1) c[cur[i]]='S';
else c[cur[i]]='R';
}
}
//for(int i=1;i<=n;i++) cout << c[i];
//cout << '\n';
for(int i=1;i<=n;i++) answer_type(i,c[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Partially correct |
19 ms |
344 KB |
Partially correct |
3 |
Partially correct |
18 ms |
508 KB |
Partially correct |
4 |
Partially correct |
18 ms |
348 KB |
Partially correct |
5 |
Partially correct |
21 ms |
504 KB |
Partially correct |
6 |
Partially correct |
21 ms |
348 KB |
Partially correct |
7 |
Partially correct |
21 ms |
348 KB |
Partially correct |
8 |
Partially correct |
21 ms |
344 KB |
Partially correct |
9 |
Partially correct |
20 ms |
348 KB |
Partially correct |
10 |
Partially correct |
19 ms |
344 KB |
Partially correct |
11 |
Correct |
19 ms |
344 KB |
Output is correct |
12 |
Partially correct |
19 ms |
348 KB |
Partially correct |
13 |
Partially correct |
19 ms |
504 KB |
Partially correct |
14 |
Partially correct |
17 ms |
512 KB |
Partially correct |
15 |
Partially correct |
20 ms |
348 KB |
Partially correct |
16 |
Partially correct |
20 ms |
348 KB |
Partially correct |
17 |
Partially correct |
21 ms |
500 KB |
Partially correct |
18 |
Partially correct |
21 ms |
348 KB |
Partially correct |
19 |
Partially correct |
23 ms |
344 KB |
Partially correct |
20 |
Partially correct |
19 ms |
504 KB |
Partially correct |
21 |
Correct |
17 ms |
504 KB |
Output is correct |
22 |
Correct |
16 ms |
348 KB |
Output is correct |
23 |
Correct |
15 ms |
348 KB |
Output is correct |
24 |
Partially correct |
19 ms |
348 KB |
Partially correct |
25 |
Partially correct |
19 ms |
560 KB |
Partially correct |
26 |
Partially correct |
19 ms |
348 KB |
Partially correct |
27 |
Partially correct |
18 ms |
348 KB |
Partially correct |
28 |
Correct |
17 ms |
348 KB |
Output is correct |
29 |
Partially correct |
21 ms |
504 KB |
Partially correct |
30 |
Partially correct |
21 ms |
344 KB |
Partially correct |
31 |
Partially correct |
20 ms |
348 KB |
Partially correct |
32 |
Partially correct |
20 ms |
508 KB |
Partially correct |
33 |
Partially correct |
17 ms |
348 KB |
Partially correct |
34 |
Partially correct |
21 ms |
348 KB |
Partially correct |
35 |
Partially correct |
21 ms |
348 KB |
Partially correct |
36 |
Partially correct |
3 ms |
600 KB |
Partially correct |