QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499719 | #9162. COVID tests | kshitij_sodani# | 10 | 4241ms | 13696kb | C++17 | 2.2kb | 2024-07-31 17:51:29 | 2024-07-31 17:51:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
pair<llo,llo> dp[1001];
long double pre[1001];
int n,t;
mt19937 rng;
int ans[1001];
int query(vector<int> xx){
vector<int> yy;
for(int i=0;i<n;i++){
yy.pb(0);
}
for(auto j:xx){
yy[j]=1;
}
cout<<"Q ";
for(auto j:yy){
cout<<j;
}
cout<<endl;
char s;
cin>>s;
if(s=='P'){
return 1;
}
return 0;
}
void solve(vector<int> yy){
if(yy.size()==1){
if(query(yy)==1){
ans[yy[0]]=1;
}
return;
}
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
int x=dp[yy.size()].b;
shuffle(yy.begin(),yy.end(),rng);
vector<int> rr;
vector<int> ll;
for(int j=0;j<yy.size();j++){
if(j<x){
ll.pb(yy[j]);
}
else{
rr.pb(yy[j]);
}
}
if(query(ll)==1){
if(ll.size()==1){
ans[ll[0]]=1;
}
else{
solve(ll);
}
}
if(rr.size()){
solve(rr);
}
return ;
/*
int ok=0;
//cout<<r-l+1<<":::"<<x<<endl;
for(int j=l;j<=r;j+=x){
int k=min(j+x-1,r);
vector<int> xx;
for(int ii=j;ii<=k;ii++){
xx.pb(yy[ii-l]);
}
if(query(xx)==1){
ok=1;
if(j==k){
ans[xx[0]]=1;
}
else{
solve(j,k,xx);
}
}
}*/
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long double p;
cin>>n>>p>>t;
pre[0]=1;
for(int i=1;i<=n;i++){
pre[i]=pre[i-1]*(1-p);
}
dp[1]={0,-1};
for(int i=2;i<=n;i++){
dp[i]={i,i};
for(int j=1;j<=i-1;j++){
pair<llo,llo> cur={1+dp[i-j].a,j};
cur.a+=round(dp[j].a*(1-pre[j]));
/*pair<llo,llo> cur={(i+j-1)/j,j};
llo xx=1-pre[j];
cur.a+=xx*(i/j);
if(i%j!=0){
llo xx=(1-pre[i%j]);
cur.a+=xx;
}*/
if(cur.a<dp[i].a){//-0.0001){
dp[i]=cur;
}
}
}
/*for(int i=1;i<=20;i++){
cout<<dp[i].b<<",";
}
cout<<endl;*/
while(t--){
for(int i=0;i<n;i++){
ans[i]=0;
}
vector<int> zz;
for(int i=0;i<n;i++){
zz.pb(i);
}
solve(zz);
cout<<"A ";
for(int i=0;i<n;i++){
cout<<ans[i];
}
cout<<endl;
char z;
cin>>z;
if(z=='C'){
continue;
}
while(true){
continue;
}
return 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 31ms
memory: 13468kb
input:
1000 0.789673 1 P P P P P P P N P P N N P P P N P N P P N P N P P P P P N P P P P P P N N P P P P P N N N N P P P P P N P P P P P N P P P N P P P P P N P P P P P P P P N P P P P P N P P P N P P P N N P P N P P P P P P P P P P P N P P P P P P P P P N P P P P P P P P P P P P P P N N N N P P P P P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 36ms
memory: 13688kb
input:
1000 0.686378 1 N P P P N N P P P P P P P P P N P P N P P P P P P N P P P P P N P N P N P P N P P P P P P P N P N P P N N P P P N N P P N P P P P P P P P P P P P N N P P P P P P P N N P P P P N P P P P P P P P P P P P P P N P N P P P P P P P P N N P N P P N N P N P P P N N P N P P P P N P N P P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 41ms
memory: 13556kb
input:
1000 0.873862 1 P P P P N P P P P P P P P P P P P P P N N P P N P P P P P N N N P P P P P P N P P P P P P N N P P P P P P P P P N P P P P P P P P P P P P P P N N P P P P N P N P P P P P P P P P P P P P P P P P P N P P P P N P P P P P P P P P P P P P P P P P P P P N P P P P P P P P P P P P P P P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 27ms
memory: 13688kb
input:
1000 0.669578 1 P N N P P N P P N P N N P P N N P P P P N N P P N P P P P P P N N N P P P N P P N N N N P P P P P P P N P P P N P P P P N N N P P P N N P P P P P P N P P P N P N P N N N P P P P N P P P P P P P P P P P P N P P P P P P P P P N P P P P P P P N N P N P P P P P P P N N N P P N P N P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 37ms
memory: 13608kb
input:
1000 0.907052 1 P P P P P P P P P P N P P P P P N P P P P P N P P P P P N P N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P N P P N P P P P P P P P N P P P P P P P P P P P P P P P P P N N P P N P P P N P P P N P P P P P P P P P P P P P N P P P P P P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 42ms
memory: 13532kb
input:
1000 0.844418 1 P P P P N P N P P P P N P P P P P P N N P P P P P P P N P P P P N N P P P N N P P N P P P P P P P P P P P P P P P P P P P P P N N P P N P P P P P P P N P P P P P P P P P P P P P P P P P P P N P P P P P P P P P N P N P P P P P P P N N P P P P P N N P N P P P P P P P P P P P N P P P N ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 31ms
memory: 13500kb
input:
1000 0.533576 1 N P P N N P P N N P P N P P P P N N P N P P P P P P P N N N N P N N N N N N P P P P P N N P P P P N P N N N P P P N N P P N P P P P N P P N P N P N N P P N N N N P N P P N P N P N P P P N N P N N P N P P N P P N N P P N P N N P P P P P N N N N P P N P N N N P P P N P P N N P P N P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 36ms
memory: 13468kb
input:
1000 0.415944 1 N N N N N N P N P N N P N P N N P N N N P N P P N P N N N P P P P N P N N N P P P N P N N N N N P N P N N N P N N N P P P N N N N P P N N N P P N P N P N N N P N N N P P N P P N N N N P P N P N N N P P N N P P P N N N N N N N N P N N N P N N N N P N P N N P P N P N N N P N N N P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 51ms
memory: 13472kb
input:
1000 0.596017 1 P P N N P N P P N N P N P P P P N N P N P N P P P P P P P N P N P P P P P P P P P P P N P P P N P P N P N P P P P N P P P P N N P N N N P N P P P N P N P N N N P N P P N P N N P P N P P P N P P P P P P P P P P P P P N P P P P N N P N P N N N N P P P P N P P P P N P P P P P N N P P P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 39ms
memory: 6204kb
input:
1000 0.157686 1 N P P P P N N N P N P P P N P N P N P N N P P N P N N P N P P P N P N N P P N P N P N P N N P P P P P N N N P P N P P P N P P P P N P N P P P N P N N N P P P P N N N P P P P N P N P P N P P N N P P P N P N N N N N P N P N N P N P N P P P P N N N P N P P N P N N P N P N N P P P P N N ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 28ms
memory: 13696kb
input:
1000 0.380215 1 N P N P N P N N N N P N P P P N N N P N P N N N P P N N N N N N N N N N N N P N P N N N N N N N P P N N P N P P N P P N N N N N P N N P P N N P P P N N N N N P N N N N P P P N N N N N N N P N N P N P N N P N N N N P P N N P N N N P P N N N N N P N N P P N N N N N P P N P N N N N N P ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 38ms
memory: 13504kb
input:
1000 0.432565 1 N N P P N P N P N N P P N N P P N P N N N N P N N P N N P N N N N N P N N N P N P N N P P P P P P N N N P N N N N P N N P N N N N P N P N P P P N P N N N N P N N P N P N N N N P P N N N N N P N N N P N N P N N N P N N P P N N P N N P N P P N N N N N N N N P N N P P P N N N P N P N N ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 33ms
memory: 13420kb
input:
1000 0.509199 1 N P P N N N P N P P P P N P P N N P P P N N N P N P N N N N N P N N N P N N N N N P N N P N P N P N N P P P N N N P N N P P P P P P N P P N N N P P N N P N P P P P P P P P P N N N N N P N N N P N N P P P P N P P P P P P P P N N N P N N P P P N N N P P P N N P N N P N P P P P N P P N ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 40ms
memory: 13628kb
input:
1000 0.381646 1 P N N P P P N N P N N N N N N N P P P N P P N P P P N N P P P N N N N N P P N P P N P P N P N N N P P N P N N P N P N N N P N N N N P N P P N N P P N N N N N P N P P N N P N P N N N N P N N N P N P N P N P P P N N P N P P N P P P P N N N N P N N N N N P N P N N N P N P P P N N P P N ...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 38ms
memory: 13532kb
input:
1000 0.42815 1 N P P P N N P P P P P N P N N N P P P P N P P N N P N P N N N N P N N P N N P P N N N P N N N P N P P P P N P P N N N N P N N P N P P P P N P N N P N P N P N N N N N P P N N P N P N N N N P N P P P N N P P N P P P N N N N N N P P P P N N N N N P P N N N N P P P N P P N P N N P N P N P...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 45ms
memory: 13352kb
input:
1000 1 1 P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P...
output:
Q 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 10ms
memory: 3892kb
input:
1000 0 1 N N C
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 4241ms
memory: 9656kb
input:
1000 0.001 300 N N N C N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P...
output:
Q 0000000000000000100000010011100000100001111001000000010101000000111110101011010101010110100001100011100010100000000000000011110000000000001000011000000101100001000100000000001110011000100000101000010110010000101000110011100000011001100000100010000110111000010000101000101010001010010010000010100000...
result:
points 0.0 0.0 translate:wrong