QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499729 | #9162. COVID tests | kshitij_sodani# | 10 | 4802ms | 4080kb | C++17 | 2.0kb | 2024-07-31 18:11:51 | 2024-07-31 18:11:53 |
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;
}
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: 34ms
memory: 3840kb
input:
1000 0.789673 1 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 N P P P P N P P P P P P P P P P P P P P P P P N P P P P P P N N P P P P P P P N P P P N P P P P P P P N P N P P P P P P P P N P P N P N N N P P P P P P P N 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 N P P P P N P P N P P P P ...
output:
Q 1001000110010011010110001010001010001000001011111010111001001110111110110110011111001100110001001001010111100110110011111011010100111101101010000010101100000000011001100100110100011001100001000010001110001010000000101000000000111010111011101111001000111111101111111001001010001110000001011110000101...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 52ms
memory: 3896kb
input:
1000 0.686378 1 P P P P P P P P N N P P N N P P P P P P N P P P N N N P P P N P P P P P N N P P P P P P P N P P P P P P P P P N P P N N P P P P P P P P N P P N P P P P N P N P P P N P P P N P P P P P P N P P P P P P P P P P P N P N P P P P N P P N N P P P P P P P N P P P P P P P P P P N P N P N P P ...
output:
Q 1100000011110101001101101010100010101111001001011110111100011001101100011000011001000000000001101011111001011011010111011111110010111011011110000011000111010111001011101100011111010101011101011110111100101101000110101110001100010010101000101010111101011101101111100010010100000011010001100110001110...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 40ms
memory: 3868kb
input:
1000 0.873862 1 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 N 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 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 P P N P P P P P P P P P N P P P N P P P P N P P P P P P P ...
output:
Q 0101111101110001111000100110110001001101000110110011111101001101110000010010001001001101101000100001010001111111001111010001111010110101100011101110001101001100111010100111101011110001011111001001100000100110000000010111111111010110101110111101010100110111001101101011101011110101000010110001000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 50ms
memory: 3896kb
input:
1000 0.669578 1 P P P P P P P P N P 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 P N P P P P P P P P N P P P P N P P P P P P N P P N P P P N P P P P P P N P P P N P P P P P P P P P P P N P P P P P P N 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 P P P P P P P P P P N P P P P P P P ...
output:
Q 0010011001010100110110111111001011011101101000111111000001011001000000001110010101111111101010110011111111110100010101110100110100000000000001000010001000110111011010001110000001000010010100000110110010010000011110000001110100011000000111101110011101110101000001000011110111101010110111111100111001...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 44ms
memory: 4080kb
input:
1000 0.907052 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 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 P P P P N 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 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 N P P P P P P N ...
output:
Q 0110100101001101010110100110010100001100001001110110000001000010111101001110100101110110101110111001011001001011000100110011001100010010000100110011010100110010101001011110110111101111111100010110101011000110010000101000010111010001101111110111000010101110011110010101010000111011010000000000001011...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 41ms
memory: 4004kb
input:
1000 0.844418 1 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 P P P P P 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 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 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 N P ...
output:
Q 1011110011110100011100000001111101011110111000101011101011010011001000010010100010111101010111000010101110101100101100001000010111011011111100010001001000101001101000101111000010100101001000001000010011010001011110101011001001110010111000100110101111010111101010101000010010100001011101000010110010...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 39ms
memory: 3868kb
input:
1000 0.533576 1 P P P P P P P P N P N N P P P N P N P P P P N N P P P P P P P P N P P P N P P N P P P N P P P P P P P N N P P N P P P P N N N P P P P P P N P P N N P P N N P P P P P P P P N P P N P P P N N P P N P P P N P P N P P N N N P P P P P P N P P N P N P P P P N N P P P N P N P P P N P P N P ...
output:
Q 0001001011010111011000001011110001000001101011001000110100010111000010000110101101100111101100011111011101010111111011011001010100110100001101010101011000011011001000111100001110100001111011000010110000000001101110001101101101000010100001100001101111000000010111001110101011011111000110001110110011...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 40ms
memory: 4000kb
input:
1000 0.415944 1 P P P P P P N P N P N P N P N P P P P N N P P P N P P P N P N P P P N N P N P P N P P P N P P N N P N N P P P N N P P N N P N P P P P N N N N N P P P P P N N P P N P N N P P N N P P P N N P N P P N P P N P P P P P N N P N P N N P N P P P P P P P P P N N P P P P N N P P N P P P P P P ...
output:
Q 0000011000110110011010001010110100100010011101100100110111111011001000101001001001100011100000101010100100101011010110111011000000011101100110110010011101000010110011011101110111000000010000110011111000101111001101111100011111001001000111000010010101011110010000111001101100111111010001011110110111...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 33ms
memory: 3840kb
input:
1000 0.596017 1 P P P P P P P P P P N P N P P N P P P P P P P N P P N P P P P P P P P N N N P P P P N P N P N P N P P P P P P P P P N P P P P P P P N P P N N P N P P P N P P P N P N P P P P P P P N P P N P P P P P P P N P P P N N P P P P N P P P P N P N P P P P N N P P N P P N P P N P N P N P P N P ...
output:
Q 0111000001011000111001100100100000101101000010110011011100001010010100100011000100111101011000101001101101111011010111100100101101100110001101000011001110100010100010111011111001001010001011001111010111111100010101010011001101010010000001111000110100100101011100010011111000111100001000001000000100...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 23ms
memory: 3804kb
input:
1000 0.157686 1 P P P P P P N P P P P N P N N P N P P P N P P N N N N N N P P N P N P N P N P N P P P N P N P P N N N N N N P P P P N P N N P N N N P P P P N N N N N N P P P P N P P N N N P N P N N P N N P P P P N N N N P N P P N N N P P N P P P P P P N N P P N N P N N N P N P N P N N P N N P P P P ...
output:
Q 1110101101110001111110110010100101110011101010011110000001001100011000000111100110011111011101110110000000011110000110001110000010001110011000110000100001100110000101100110100000010110110000000111110110011100100001010011110111101001111100110100000101111111010011100011011011011010110010000101111001...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 44ms
memory: 4064kb
input:
1000 0.380215 1 P P P P P P P P N P N P P N N P P P N P N N P P P P N P P N P P P P N P P P P N N N P N P P P P P N N P N P N N P N P N P P N N P P P P P N N N P P N P P P P N P P N N P P P P P P P N P N P P N P P N P N N P P P P P P N P P N N P N P P P N P N N P N P P P P P N P P N N P P P P N P N ...
output:
Q 1000000010101101101011101111100010000111011101100001011101000110111111111010011001101100000010001011100101111110110001000110100111100000011110001100001010101101000100001101110110111100110100000011011101011011111100011100100111110110000000110101100110001101000100101101101000111100000010010101010010...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 29ms
memory: 3896kb
input:
1000 0.432565 1 P P P P P P P P P N N N P P P P N P P P N N N P P P P N P P P P N N N P P P P N P N P N N P P P P P N P P P P P P P N P P P P N N N N P P P N P N P N N P N P N P N P P P P P P P P P P N P P N N P N P P N N P N P P P N N P N N P P P N P P P P N N N P P P P P N N P N N P P N P P P P N ...
output:
Q 1101011010101010100010000011111110100110001110110100010111011001000101101111111000010010100001101000101001011010011010100101111110101001110110111110110101111100000100010101110000011001010000110101010010101000011110100111001110001111110100100001011011110100101100001101111111000110011010100011101101...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 43ms
memory: 4064kb
input:
1000 0.509199 1 P P P P P P P P P N N P N P N P P P P N N P P N N N P P P P N P P P N P N P P P P P N P N N P N N N P P P N P P P N P P P N N P P N P N N N P P N P N P P P P N 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 N N P P P P P P P N N P P P P P P P P N N N P P P P P P N P P P N P N ...
output:
Q 1111001010011111011010010011011110110111110111010001010000100111001001011110010101100111100110100001010101100111010011101011100111100101000000001001000111011100100011110111111110101011110000101000111111010101000100001110111001100000011001011001111010100111110010011010010101001000001011110001100101...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 35ms
memory: 3832kb
input:
1000 0.381646 1 P P P P P P P P P P P P N N P P P P P N P N P P P P P N P N P N P N N P N P N P P N N P P P P P P N N P N P N N P P N P N P N P N P P P P P N P N P N P N P P P P P N P P P N P N P P P P P P P P P N N P P N P N P N P P P N P P P N P P P P N N P P P P P P P P P P N N P P P P P P N P P ...
output:
Q 1100001111110111000110000010111110100100001101010010011001101001111100000101001001101100100101000101011000111011011001000000011011100001010000011100000101011110001011111100111001110110010110011100101100001110010010110010111100001001100010110101110010111011111110110100010001001110001101000010010001...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 35ms
memory: 3844kb
input:
1000 0.42815 1 P P P P P P P N P P P N N P P N P P P P N N P N P P P N N P P P N N N P N P N N P P P P P P P P N N P P P N N N P N P P N P P P P P P N N P N N P P N N P N N N N P P P P P P P N P N N P P P P P N N P N N P P N P P P N N P N P P P N P N P N P N P P N P P P N P P P N N P N P P N P N P P...
output:
Q 0011011111111110101010111010110111111111001111011011001101001011111110011100001110100111100100011011010000010010001011001100101100010000100000111010010110110001011000110101111000110000110111001100011001101111011010111010100100110110100111100101001110111101010100111111111011000110010001101110010101...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 43ms
memory: 3900kb
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 0011101010111001110111010111100011100010001010100000100010001110010000100101001011011110010001011101010010100001011101111110011001000110111001001100110110101111001110001010001011011111100000111000100111000111110011100000111100000010000010010000000111101110101010110110011011010110110001100001011110...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 1ms
memory: 3844kb
input:
1000 0 1 N N C
output:
Q 1110000001000011001111000111010100001001110000100101100001010011100001101001111011010110011001010001100001010101101000001011100110001100011111101010111101101011111111111010100111110000111001001100010011010110111111011110110001000101111101001010110111001110111111000011010000000001010011011100110001...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 0
Time Limit Exceeded
Test #18:
score: 43.7
Acceptable Answer
time: 175ms
memory: 3900kb
input:
1000 0.001 300 N N C N P P N P P P P N P P N P N N N N N N N N N N C P P P P P N P N N P N P P P P N N P N N N N N N N N N P P N P N P N P N N P N N N N C N N C N N C N P N P N P N P P N P N P N N P N N N N C N P P P N P N P P N P N P P N N N N N N N N N C N N C N N C P N P N P P P N P P N N P N N N...
output:
Q 0101011101011111001101000000001000001101001001110111100001011111010010101110010100011000100101100001011111100100001110010110001100010011000111000100100001100110000001101101101110100111011110100111011100101101111001010110111100001111110111110101000001110001010001100001010110011011011000100101000101...
result:
points 0.48555555560 0.4855555556 Output is correct (P=0.001, F=15.1, Q=19.1) -> 43.70 points
Test #19:
score: 24.85
Acceptable Answer
time: 688ms
memory: 3892kb
input:
1000 0.005256 300 P P N P P N P P P N P N N P N N N N N N N P N P N P P N P P P N P N N N N N N N N P P P P P N P N P N P P N N N N N N N N N P P P N P N P P P N P N N N N N N N N P P P N P N P N N P N N N N N C P N P N P P P P N P N P N P N N N N N P N P N P N P N P N N N N N N P N P N P P N P P P ...
output:
Q 0100010111011110011101101111111011010101100101101101110110010100110100001011100100000001010001111111000101000010011011101100100010100011011110011100000001100111100001001001101101010011001110011010111010100001100110101010100010100111100101001100000011110101100001101011000001011011010100011011111001...
result:
points 0.27611111110 0.2761111111 Output is correct (P=0.005256, F=51.1, Q=84.6) -> 24.85 points
Test #20:
score: 23.36
Acceptable Answer
time: 1435ms
memory: 3840kb
input:
1000 0.011546 300 P P P P P P N N P N N N N N N P P P N P N P N P N N P N N P P N P N P N P P N N N N N N N P P P P N P P N P N N N N P N P N N P N N P N P P P N N P N P N N N N N P P P N P P P N P N P N P N N N N N N N P P N P N P N P P N N P N N N N P N P N P N P N P P N N N N N N P P P P P N P P ...
output:
Q 1101010100111000011000110101010011001000110011000101100010000000100000011111110100011101010010110111011011100100010111000111000000100000100111000000010001001100011101000100100110001011000110111111000110111011100110011110100111100011001000110000001001101010010101001100000101000000101001011101101101...
result:
points 0.25955555560 0.2595555556 Output is correct (P=0.011546, F=94.9, Q=162.6) -> 23.36 points
Test #21:
score: 23.97
Acceptable Answer
time: 2679ms
memory: 3896kb
input:
1000 0.028545 300 P P P P P N P P P N N P N N N N N P N P N P N P N N P N N N P P P P N N P P N P N P N N N P N P N P N P N N N N N N P N P P P P P N P N N N N N N N P P P P P P N N N N N N N N P P P P P N P N P N N P N N P N P P P N P N N N N P P P N P P N N N P N P P N N N N P P N P N P N N N N N ...
output:
Q 0001010101111111001110100110011100101001110100011101010101000101011000001100110110110111111110100100111010011111011010011101111011100000111101100001011110101001010110100001110011010100101011101011000000101100110001000111000010000101011010101110100100011001001111000111110011011111110011000010110101...
result:
points 0.26633333330 0.2663333333 Output is correct (P=0.028545, F=191.5, Q=323.4) -> 23.97 points
Test #22:
score: 24.69
Acceptable Answer
time: 3491ms
memory: 3844kb
input:
1000 0.039856 300 P P P N P P N P P P N P N N N N N N P P P P N P N N N N N N N N P P P N P N P N P N N P N N N P P N P N P N P N N N N N P P P P N P N P N N N N N N N N P P P N P N P P N N P N N N P N P P N P N P P N N N N N N N P P P N P N P P P N N N N N N P P P N P P N N N P N P N P N N N P N P ...
output:
Q 1010010111101111001001000111101001001010110011110001110111111001010100011000001010010001011000110100100000011110010101000001111110010000010001000001000110010110110101000101011100101011101011101110000000111000001001011101100010011010110001111100000110100100000010101010011100110111111001000011100001...
result:
points 0.27433333330 0.2743333333 Output is correct (P=0.039856, F=246.3, Q=409.2) -> 24.69 points
Test #23:
score: 26.92
Acceptable Answer
time: 4802ms
memory: 3912kb
input:
1000 0.068648 300 P P P P P P P N P P N N N P N P P N N N N P P P N N P N N N N N P P N P N P N P N N P P N P N N P N N P P N P N P N P N N P N N N P P P N P N N P N N N P P P P N N N P P N P N N P N N N N P P P N P P N P N P N N N P N P P P P N P N N N N N P N P N N P P N P P P P N P P N N N N N N ...
output:
Q 1001011001101011110111111011000110110111010100000001100011101110110101101101110101010000001010001001011100100101100101011111111001100010110111011000101101110000001001011101010100011111110001100110111100010011101101001110011101000011111110101101110001100000011000000111011101100110010111000111000001...
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 P P P P N N N N N N P P P N P P N N N N N P P P P P N N N N N N P P N P P N N N P P P N N N N N N P P P P N P N N P N P P P N N P P N N N N P P N P P N N N N N N P N P N P P P N N N N N P N P P P N P P N P P N N N N N N P N P P P P N N N N N N P P P N P P N N P P N P N P ...
output:
Q 0000001111000011111010011001100100001001111001101011011110000111000001011001010100100010011011010000000000011011010001111001101110111111010010111011001010001100001001100011100011111001101101001011101001111101011110111110111011010010011010110110101110011110011010110111001110011111101101000111110010...