QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499726 | #9162. COVID tests | kshitij_sodani# | 10 | 4606ms | 4064kb | C++17 | 2.1kb | 2024-07-31 18:10:04 | 2024-07-31 18:10:05 |
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<long double,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(int l,int r,vector<int> yy){
if(l==r){
if(query(yy)==1){
ans[yy[0]]=1;
}
return;
}
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
int x=dp[r-l+1].b;
shuffle(yy.begin(),yy.end(),rng);
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(l>0 or r<n-1){
if(k==r and ok==0){
if(j==k){
ans[j]=1;
}
else{
solve(j,k,xx);
}
continue;
}
}*/
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,1};
dp[i].b=(i/2);
continue;
for(int j=1;j<=i-1;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;
}
}
}
/*cout<<'{';
for(int i=0;i<n;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(0,n-1,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: 38ms
memory: 4000kb
input:
1000 0.789673 1 P P P P P P P P P P P P N P P N P P N P P P P N P N N P P P N P N P N P N P P N P P P P N N N 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 N 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 N P P P P P P P N P P N P P P P N P P P P P P N P P P P P P P N P P P P P P ...
output:
Q 0100000111110100111011000101110010110001111011100000110011011100101111100001011111001000111111110010110101100100111011100010110011101011001000100010001101011111111111000000101101101000100010001000111111001000110111011100101010101100111001000111101101000110010101100010101111001011111100010011101011...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 52ms
memory: 4064kb
input:
1000 0.686378 1 P P P P P P P P N N P P N P P N P P P N N P N P P P N P P P P N P P N P P N P P P N P P N P N N P P P P P P N N P P P P P P P P P N P P N P P P P P P P N P P P N P P P P P P N P P N N P N N N P P P P P N P N P P N P P P P N N P P N P P P P P P P N P N P P P N P P P P P N P N P P N P ...
output:
Q 1011101001110011101101001101110100100000101101101101101101101010100010001111001111010011111000110111110011111000101100000100101001001111000100111110100100010000110100010001110011010101100100001101101001000100100100001101110011011100011001000001010010010010010010111000101110011101011111000010010110...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 45ms
memory: 3888kb
input:
1000 0.873862 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 N N P P P P P P N N 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 P P P P P P P 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 P P P P P P P P P P N P P P ...
output:
Q 0110000001100001010000101010001100100101011101001000000100111110101001001110010000101100110000000111110101111010100001111111110100010001011010100101001000000110110000101010110100011111000000000010111101101110101011000111000100100100110111000101001000010011000011011001100110111010010000001110010111...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 33ms
memory: 3832kb
input:
1000 0.669578 1 P P P P P P P P P N N P P N P N P P P N P P N P P P N P P P N P P P P P N P P P P N N P N N P P N P P P P P P P N P P N P P P P P P P P P N N N P P P P P P P P P P N P P P P N P P P P P P N P P P P P P P N N P N N P P P P N N P P N P P P N P P P P N N P N P P N P P P P P P P P P P N ...
output:
Q 0010101101011011100010111110010111110100001101111001011101011010100100101101111000000000001111000000100010000101101010111000000111100100010010001000101101001010111100011001000101000101100100000010101000101100100001000111101100100001110011001111001011011100001100001111011001111110100010011001101010...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 39ms
memory: 3800kb
input:
1000 0.907052 1 P P P P P P P P P P P P P P N P P P P P 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 P 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 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 P P P P P P P P P P P N P N P P P P P P P N P P P P P P P P P P P P P P ...
output:
Q 0101011100000011000000010000011101101010010111111011001100111001000011111000110100101100000111110010000110011010100010010010001011101000101011110011000111000100101010101111101101010100110100001101110111110010010101111000011000110011010101001000011001001110100011001100011011110011011001000101110010...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 47ms
memory: 4036kb
input:
1000 0.844418 1 P P P P P P P P P P N P N P P P P P P P 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 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 N P P P P P P P P P P N P N P P P P P N P P P P P P P P P P P N P P P P P N P P P P P P P P N P P P P N N P P P N N P N ...
output:
Q 1101111101001100000100011111101000111101110101111101110100001000011110100111000110111011000010110110000000111001011110000011111110100011000000101101011010011111011110000011010001111011100000000100101111001001010110110101100100101001100101110100100110111011100110001011101000000011010111001100011001...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 41ms
memory: 4064kb
input:
1000 0.533576 1 P P P P P P P P P P P P N N P N P P P P P P N P P P P P P N P N N P N P P P N P P P P N P P N P P P N P N P P P P N P P P P N N P P P N P N P P P N P P P N N P P P N P N N P P P P P P P P N P N N P P P P N N P P N N P N N P P P N P P N N P P N N P P N P N N P P P P P P P P N P N P N ...
output:
Q 0110011101001111000000010000101001110101100111001011110101011100001010001101101010000001011011010001000000001000010000010011100010111111001010110110100011001001111111000000111110111100111101011001110100111110010110111000101100000111000101100110101111101110001011011000010101000001110110110110110010...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 36ms
memory: 3892kb
input:
1000 0.415944 1 P P P P P P P P N N P N N P N P P N N N P P P N P P P P N P N P P N P N N N P P P P N N P P N N P P P P P P N P P N P P N P P P N P P N P P P N P P N P P P P P P P P N P P P N N P P P P N N P P N P N N P P P P N N P N P P P P P N P P N N N N P P P P P P P N P P P N N P P P N N P N N ...
output:
Q 1111011110001001101000010000111001011010101001111110011111100000011110011110000001100011001101010011010100000100011001100000011001110011101000011001111100100100011001010001010111010101011101011010110101000011001010001000111000011101011001111011100000001000111000111110001101100100010011100110001001...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 45ms
memory: 4000kb
input:
1000 0.596017 1 P P P P P P P P P P N P P N P P P P N P N P N P P N N P P P P N P P P P N N P P N N P P P P P P P P P P P P N P N P N P N P P P P P N P P P P P P P P P N N P P P N N N P P N P P P P N P P P P P P P P P P P P P N P N N P P P P N P N P P P N P P P P N P P P P N P P P P P P P N N P P P ...
output:
Q 0011101101101000001100111111001000110110000100010010100110110100001000101001111111101010100001001110100101001110010100101010110111011000001001011110011000001101010100001101101000100000111011001001110011000011111010001110010000011110101011011101101011110111010111000001010011101010110000001110011001...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 29ms
memory: 3892kb
input:
1000 0.157686 1 P P P P P P P N P N N P N P P N N P P N P N N N P N P P N N P P N N P N N N P P P P N N P N N P N P N P N P N P P N P N P N N P N P N N P N N N P P P N P N P N N P P N N N P P P P P N N P N N P N P P N P P N N N P P P P P N N N P P P N P P N P N N N N N P P P P N P P P P N N N N P P ...
output:
Q 1001100000110001101101000101011101001111001001010101001101110000011100001110010100110001011000110110111001000111110100011101001011010000111001011010100111011111101100110001001110100111111101100010100001000011110001101001101110111100001011011101100010110111101010110101000101101110010011011100000111...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 36ms
memory: 3968kb
input:
1000 0.380215 1 P P P P P P P P N P N P P N N N N N P P P P P P P N P P N P P N P P P P N P N P N P P P P N N P P N P P N P P N P N P N P N N N P P P P N P P P N N P P P P N N P N P P N N P P P P P N P N N P P P N P P P N N N P P P N N P P N P N N P N P N N P P N N P P P P P P N P P N N N P P P N P ...
output:
Q 1101000011100010100011000111111010101011101101101100010011100011111000010001101110011100111111011010100011111001010010110010001100110110011010000010010000101110001101010010010111110010001000110111011001111010100000001011010000010001001001011000110001010111010101110001101100001110010000100000111100...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 42ms
memory: 3844kb
input:
1000 0.432565 1 P P P P P P P P P N P P P N N N P P P N N P N P P N N P P P N N P P N N P N P P N N P P N N P N N N P P P N P P N N P P N P N N P P P P P P N P N P P N N P N P N P P P P P N P P N P P P N P N P N P N N P P P P N N P P P N N P P P P P N P N N P P N N P P P N P N P P P P P N P P P P N ...
output:
Q 0011001010010100100111100111110110001001101101001111001110110010111001011111100000001111110110111100001101000101110001101011010100101001110110011001111110011011110011010010001100110011000010011100011000100111001100001101000010010001000001101101100100010110101110110100011011000111111100110110010011...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 35ms
memory: 3872kb
input:
1000 0.509199 1 P P P P P P P P P P P P P N N N P N P P N P N P P P P P P P P P N P N P P N P N P P P P P P P P P P N P N P P P P P P N P N N N P P N P P N N N P P P P N P P P P N P P P P P P P N P P P N N P P P P N P N N P P P P P N N P P N N P N P P N N P P N N P P N P P P P N P N P N P P N P P P ...
output:
Q 0101110010011101101101001000010100001001110110000100101000000011001000000110011001010100101000110111110000001000100011011101000000011111111100111001111011111000111100100101010001000100100011000000110011110101111010111111101001001010001010000001001100001011000001100011101111111010010010010100010010...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 39ms
memory: 3848kb
input:
1000 0.381646 1 P P P P P P P N N P P P N P N N N N P P P P P N P P N N P P P P P N P N P N N N P P P P P P P P P P N P P N N P P P N P P P N P P P P P N P N P P P P P P P P P P P P N P P N P P P P P P P N N P N N P P P P P N P P N N N P P P N P P P N N N P N P P P N P P N N N P P P P N P P P P N P ...
output:
Q 0001111101110011100010100110010011010100100100010011110111010110110111001101100111111111110010110001101000110100010111010111101101100001100110001010000110011010000101000111111001111010101000000000110000100100001111010001000011111100010111110101101011101101001100000100110110000110010101010111010110...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 40ms
memory: 3896kb
input:
1000 0.42815 1 P P P P P P P P P P N P P N N N P P P P N P N P P P P P P N P P N P P P P P P P P N P P N P N P P P P P N N P P N N N P P N P N P N N P P P P P P P N N P N P N N P P N P N P P N P N N P P P P P P N P P P P P N N P P P N N N P N P P P P N N P N N P P P P N P N N N N P P P P P N P P P P...
output:
Q 1100100011111101110001111100000011011110111011000001111011001010111101011111111010101000101011010011101110010010100110110001010100101011110100010110101000111100001101101100101001111001011010100101100100111101111010000000100010011100011100000111010011011000110111101001110010100001100011101011000111...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 41ms
memory: 3832kb
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 1001010110101001111110010000100000001100010111110001101010110110010111000011110110011011001011001001000000110100000101000010010110110010101001100110100101010000110101011110011011011001111011101100111101101100111001001100010100101100111001111100111010100000011000111000101011111010111101000000111000...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 1ms
memory: 3836kb
input:
1000 0 1 N N C
output:
Q 0100101001100011001000100110011110101100010111010010001100000101111010001000111100101101111001000100011101111111011010100101100111011000000000101010000000111111001000110100010010100000001100010111011001111100100100010101000110010110100001010110101010010000111000011010100010101010110011110110111111...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 0
Time Limit Exceeded
Test #18:
score: 43.14
Acceptable Answer
time: 168ms
memory: 3836kb
input:
1000 0.001 300 N N C N P N P P N P P P P P P N N N N N N N N N N N C P P P N P P P N P P P N N N N N N N N N P N P P N P P N P N N P N N N N N N P P N P P P P P N P N N N N N N N N N N N C N N C N N C N P P P N P N P P P N P N N P N N N N N N N N C P N P P P P N P P N P P N N N N N N N N N N N C N N...
output:
Q 1110000111001000101010000010101000110100111101100101010010101000000000111101101100001101000110001010111010011001011100011111100110011001011110110001010100000001000111001111000100111111111011000011000101010001001001111001000000000111000010011000010111111011001011001111101101110000110100110010010111...
result:
points 0.47933333330 0.4793333333 Output is correct (P=0.001, F=15.1, Q=19.2) -> 43.14 points
Test #19:
score: 24.79
Acceptable Answer
time: 722ms
memory: 3892kb
input:
1000 0.005256 300 P P P P N P N P P P P N N N N N N N P N P N P P N N P N N N N N P P N P N P P P N P N N P N N N N N N N P N P N P P P N P P N N P N N N P N N P N N C P N P P P P P P N P P N N N N N N N N N N N P P P P N P N P P N P N N P N N N N N N N P P P N P N P P N P N N P N N N N N N N C P N ...
output:
Q 1100111001111101000100000100001101000110111110000111101011001011110100010000001010011000100100101000101001000010000010000110011000000000001101011000011000001110101010000011111101101010001111010110001010101010110100000010000000111001010010100111101110001101010100001111011110101000000001100011000010...
result:
points 0.27544444440 0.2754444444 Output is correct (P=0.005256, F=51.1, Q=84.7) -> 24.79 points
Test #20:
score: 23.43
Acceptable Answer
time: 1308ms
memory: 3868kb
input:
1000 0.011546 300 P P N P P P N P P N N P N N N N N N P P P P N P P N P P N N N N N N N P P N P P N P P N N N N N N P N P P N P N N P N N N N N P P N P N P P P N P N P N P N N N N N N N P P P N P P N P P N P P N N N N N N N N P P N P N P P N N P N N N N N P P P P N P N P N N P N N P N P P N N P N N ...
output:
Q 0011111111111011110101001001110101000000100110110010100001110110100011011110110100011110100100010000010001001110110101111111101001101001100111011010101001110010111111111111010101101100101011011001101000111101010001111001110100000110010011101010010011101101010111000111110110010100101001001101001100...
result:
points 0.26033333330 0.2603333333 Output is correct (P=0.011546, F=94.9, Q=162.3) -> 23.43 points
Test #21:
score: 24.2
Acceptable Answer
time: 2619ms
memory: 3904kb
input:
1000 0.028545 300 P P P P P P N P P N N P N N N P P N P P N N N P N P P N N N N N P N P P N P P P N N N N N P P P P P P N N N N N N N N N N P P P N P P N P N P N N N N N P P P N P P N N N N N N N P P N P P N P N P N N N P N P N P N P N P P N N N N N N P P P N P N P P P P N N N N N N N P N P N P N P ...
output:
Q 0100001000001101101010100101000011001111001110001101010110110011100100000001000101110000010100110000000110110111111001110110110001101001000001000111010001111101111111011100010100001100100000001000000111110100000100101010110011111111101010001010101101011100110100110101001110010001111011001110010101...
result:
points 0.26888888890 0.2688888889 Output is correct (P=0.028545, F=191.5, Q=321.7) -> 24.20 points
Test #22:
score: 25.03
Acceptable Answer
time: 3330ms
memory: 3892kb
input:
1000 0.039856 300 P P P N P N P N P P N P N N P N P N N P N N N P P N P P N P P N N P N N N P P N P P N N N N N N P P N P N P N P P N N N N N N P P P P P P P P P N N N N P P N P N N N N P P N P P N N N P N P N P P N N N P P N P P P N N N N N N N P P P N N P N N N N P P P P P N P N P N N N N P P N N ...
output:
Q 1001011010100010110010101010110100001101011110011010000011011011101111011100001011111100001011010100010001101000111111110111001011000011000001010111110001011011110000101100011010100001110101100111100000100100000010000100010100011010110111100100110011100111011100111001100100001101010111100111000101...
result:
points 0.27811111110 0.2781111111 Output is correct (P=0.039856, F=246.3, Q=406.1) -> 25.03 points
Test #23:
score: 26.92
Acceptable Answer
time: 4606ms
memory: 3840kb
input:
1000 0.068648 300 P P P P P P N P P P N N P N P N N N P N P N P N P N N N N P P P P N N P N N N N N P P P P N N P P P N P N N P N P N P P N N N N N P N P P N P N N P N P P N P N N N N N N P P P N P N P N P P N N N N N P P P P N N P N N N N P P N P N P N N N N N P P P N P P P N N N N N P P P N P N N ...
output:
Q 0010011001001110111010001111000011011011101011101100000101110111100100010110101101110101101010001011011100010100011010011010001000110010100010010010001101011000101101101001100111010001010011100001111010001000110000000010100011101010010101110100110011001000000110110100111001000101111101101110000101...
result:
points 0.29911111110 0.2991111111 Output is correct (P=0.068648, F=366.2, Q=580.7) -> 26.92 points
Test #24:
score: 0
Time Limit Exceeded
input:
1000 0.104571 300 P P P P P N P P N P N P N N N N N P P P N P N P N P N N P P P P N N N N P P N P N N N N P P P P N P P N P N P N N P N N N N P N P P N P N N P N N N N N P P P P N N P P P P P N N P N N P P N N N P P P N P P N N N P P N N P N N N P N P N P P N N N N N P P P P P N N P P N P P N N N P ...
output:
Q 0101100100101000011011011010111111001100001000000001000011110010111111100100010000000100100001110000000110010001010000110000010100110001010000111110111011111010110110100101011100100111001001100011110000111100111000101010111000110100101000011100101010011010110101110111110001111110111011100100100010...