QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499715 | #9162. COVID tests | kshitij_sodani# | 10 | 4927ms | 4460kb | C++17 | 2.0kb | 2024-07-31 17:42:00 | 2024-07-31 17:42:00 |
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};
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;
}
}
}
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: 55ms
memory: 4372kb
input:
1000 0.789673 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 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 N 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 ...
output:
Q 1111111111111111111111111111111111111111111111110111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111011111111110111111111111111111111111110111111111111111111101111111101111111111111111111111111111111111011111111111111111111111111111111111111111111111101...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 50ms
memory: 4244kb
input:
1000 0.686378 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 N 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 P P P P P P N P P P P N P P P P P P N N P P P P N P P P P P P N P N 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 N P P P P P P P N P P P P P P ...
output:
Q 1111111111111111111111110101111111110011111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111101111011101111111111011111111111111111111111111111111111111110111111111111111111101111111111111111111101111111011111111110111111111111111111111111111111111111101111111...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 60ms
memory: 4256kb
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 P P P P P P P P P P P P P P P P P P P P P 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 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 ...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111010111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 52ms
memory: 4204kb
input:
1000 0.669578 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 N P P P 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 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 N 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 P P P 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 1111111110111111111111111111111111111010111110111111111111111111111111111111111111110111111111011111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111110110111111111111111111111111111111111111111111111111111111111111111111011111111111111111...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 46ms
memory: 4460kb
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 P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P 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 ...
output:
Q 1111111111111111111111011111111111111111111111111111111111111111111111111111111111111111101111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111001111111111111011111111111111111111111111111111111111111111...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 60ms
memory: 4196kb
input:
1000 0.844418 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 N P P P N P N 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 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 N P P P P P P P P P N P P P P P P P P P P ...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111011111111111111110111111111111111110111111111111111111111111111101111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111001111111111...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 49ms
memory: 4024kb
input:
1000 0.533576 1 P P P P P P P P P P P P P P P P P P P N P N P P N P P P P P P N P P P P P P P N N P P P N P N P P P P N N P P P P P P P P P P P N P P P P P N P P N 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 P P P P P P P P P N P N P N P P P P P P N P N P P P P N P N P P P P N P P P N P P P ...
output:
Q 1111111111111111011111111111101111111111111111111111111111011101111111110101111111111111111110111111111111111111111111111111110100111111111111111111111111111111111011111111101111110111111101111111111111111111111111111111111111111111111111111111110111111111111110111111011111111111111111111111111110...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 56ms
memory: 3980kb
input:
1000 0.415944 1 P P P P P P P P P P P P P P P P P N N P P P N P N P P P P N P N P P N P N P P P N P P P P P N P P P P P P P N N P P P P P N P P N P P P P N N P P P N P P P P P P P N N P P P P N P P N P P P N P N P P P P P P N P P P N P N P P P P P N P P N P N P P N N P P N P P P P N P P P P N P N P ...
output:
Q 1111111111011111101111111111111111111111111111111111101111011111110111111111111111111111111111101111111111111111111111111111111111111111111101111011111111111111111110101111111011101110111001111111111101011111111100011111111111101111111111101111111111111101011111111111011111111111111111111111111110...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 52ms
memory: 4008kb
input:
1000 0.596017 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 N 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 P P N P N P P P P P P P P P N P P P N P N P N P P P P N P P P P P P N P P P N P P P P N 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 N P N P P P N P P P N P P P N P P P P P N ...
output:
Q 1111101111111111111111111111111111111111111111111111111110111111111111111111111111111111111110111111111111111111111110111111111111111111111111111011111111111111111111111111111111111111111111111111101111111111111101111111011111111111101011111111111111111111111111111111111010111111111111110111111110...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 36ms
memory: 3884kb
input:
1000 0.157686 1 P P P P P P P P P P N P N P N P N P P P N N P P P P P N P N P P P P N N P P P N P N N P P P N P N P P N P N P N P P N P P P P N P N N N P P P P P P P N N P P P N N P P N P P P P N P P N P N P P P P P N N P P P P P P N N N P P N P P N P N P P P P P N P P N P N N P P P P N P P P P N P ...
output:
Q 1110000011101111011111001111100011001111110001100111101110111111010001111011111111101111111111011110111111010011110111011111111111011111110111101110111101110111111000111101011101100111101111001100011110111111010111111101101110101101111111111111111111110111011111111111101011100000011111111111111011...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 50ms
memory: 3964kb
input:
1000 0.380215 1 P P P P P P P P P P P P P P P P P N P P P N P P P P P N N N P P P P P P P P N P P P N P N P P P P P N P P P P P N N P P P P N P P P N P P P P N P P P P P P P P P P P N P P P P P P N P N P P N P N P P P N P P P P N P P P P P P N N P P P P P P P P N P P P P P P P P P N P P P P N P P N ...
output:
Q 1111110111111101111011111111111111111111110111111011111111110110111111111111111111011111111111110111110111011111111110110111111111110110111110011111111111111110111101111111101111111111111110101011111111011111111111111111111111111111001111111111111111111111101110111111111111111111010111111110111111...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 50ms
memory: 3988kb
input:
1000 0.432565 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 N P P P P P P P N N P P P P P N P P P P P N P P N P P P N 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 P P P P P P P P P P P P N P P P N N P P P P N P P N P N P P P P P N P P P P N P P P P P P N P P P N P P P P N P ...
output:
Q 1111111111010111111111111111111111111111111011111111111011111111111111111111111111100101111111111111111111111111011111111111111111111111111111111111111110111101110101101111110111111101111111111111111111111111111111111111111111111111111101111111111011111111111111111111110111111111111111111111111011...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 48ms
memory: 3952kb
input:
1000 0.509199 1 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 N P P N P P P P N N P P P P P N P P P P P P N N P N P P P P P P N P P N P P P N P N P P P P P N P N P P P N N P P P P N P P P P P P P N P P P P N P P N P P P P N P P P P P P P N P P N P P N P P P P P P P N P N P P P P N P P P P P P P ...
output:
Q 1111111111011111111111111011111011011111111110111101111111111111111111100111111111111111111110111111111111111111110110111111111111111111111111111111111101111111111111111111111111111111111111111111111111110111111111111111101101111111111111111111111111111111111111111111101111111111111111111111101011...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 48ms
memory: 3968kb
input:
1000 0.381646 1 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 N P P P P P P P P N P P P N P P N P P P P P P P N P N P P P N P N P P P P P N N P P N N P P P P N P P P N P P P P P N N P N P P P P P N P P N P P P P P N P P P P P N P N P P P P P P P N P P N P P P P N P P P P P P P P P P P P N N N ...
output:
Q 1110111111111111111111010111111111111011111101011111111110111111101111011111111011111110111110110110111101011111111111111111101111111111111111101111111111111101111110100111111111111111111111101111111101111011111111111011110111101111111111011101111101111111111111111111111110100111101110111111111011...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 58ms
memory: 3988kb
input:
1000 0.42815 1 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 N P P P N P P P P P P N N P P P P P P N P P P N P P P P N P P N P N P P N P P P P P P P P P P N N P N P P N P P N P P N P P N P N P P N P P P P P N P P P P P N P P P N P P P P P P P N P P N P P P P P P P P P P P N P N N P P P P P P P...
output:
Q 1111111111111111111111111111111111111111111101110111111111111111111111110111011011111111111111111111111111111111111111111111111101111111111111111111111111111101111111111100111111111111111101011111111111110111101101101111111111111111111111111011111111111111011111101111111111111111111111111111110111...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 51ms
memory: 3936kb
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 1100100110001111111000010010100011000001000010011000000001000001001100011110001100001001010101111010010101010011010101100011001001111110111000101100111111101010111110001101110011011010010100010010000011000111111101101011111001010011111100100001011111010100101011010101100011100000110111101000110110...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 5ms
memory: 3968kb
input:
1000 0 1 N N C
output:
Q 0101111010100011011010101110101110100110010111001010110100010100001001001000100100100100011100100011110000000010011010011111110000000011111101101010100100101011010011100011011000110111011111101111010111011010011000010110110001011010000111101010000000111010100110100011000011100100100101110011010001...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 0
Time Limit Exceeded
Test #18:
score: 53.29
Acceptable Answer
time: 178ms
memory: 3968kb
input:
1000 0.001 300 N N C P P N P P P N P N P P N P P N N N N N N C N P N P P N P P N P P N P N P P N P N P P N P N N P P N P P P N P N P N P N N N C N N C N N C N P N P P N P N P P N P P P N P N N N N C P P P P N P P P P P N P N N N N N N N N C N N C N N C P N P N P P N P N P N P P N P N P N N N C N N C...
output:
Q 1110111100111011110000110111010011100010101000100000011000011001101011000010010001100000111101100000111001011110011101100010110111101111000101101110110000101101011101100001000101100101110111010011001110111001100001101010110100001111000001111011010111010010011011010100011101000011110111011000101001...
result:
points 0.59211111110 0.5921111111 Output is correct (P=0.001, F=15.1, Q=17.7) -> 53.29 points
Test #19:
score: 29.96
Acceptable Answer
time: 684ms
memory: 4068kb
input:
1000 0.005256 300 P P P P N P N P N P P N P N P N N N P N P N P P P N P P N P P N N N N P P P P P N P P P N P P N N N N P N P N P P N P N P P N N N P P P N P N P N P N P N P N N C P P P P P P P P N P P N N N N N P N P P N P N P P P N N N N N P P N P P N P P N P P P P N N N N N N C P N P P P P P N P ...
output:
Q 1001010101111010100001101010110110000111000011111011110010000111010010100011011000011111011100010100000101011010101100101001011110001101001111010101101010101001110101111010101110010010011111010100001101011001110011100110000010101110100101001011111110011010001011000001110100110110000111111001000011...
result:
points 0.33288888890 0.3328888889 Output is correct (P=0.005256, F=51.1, Q=76.7) -> 29.96 points
Test #20:
score: 27.26
Acceptable Answer
time: 1330ms
memory: 3896kb
input:
1000 0.011546 300 P P P P P N P P P N P P N N N N P N P N P P N P P N P N N P P P P N P N P N P P N N N N P P N P N P P N P N P N P N P N P P P P P P P P N N N N N P N P P P P N P N N N N P P P P N P P P P N P N P P N P P N N N P P P P N P N P N P N N N P N P N P N P P P P N P N N N P N P P N P P N ...
output:
Q 1110101010100000010101010010000100010001011011111000001100111110001100101010100001100101111100011101011010001010001001000001010110010111101100000110001101111001111010111010011111000110101101100010111100100100000100100100011000010100000011110000111000101110110111000100110101111110111101111001101101...
result:
points 0.30288888890 0.3028888889 Output is correct (P=0.011546, F=94.9, Q=149.5) -> 27.26 points
Test #21:
score: 27.4
Acceptable Answer
time: 2499ms
memory: 4036kb
input:
1000 0.028545 300 P P P P P N P N P N P N P P N P N P N P P N P P N N P P N P P P P N P N N P P N P P N N N P P N P P P N P N P N P P N P N P P N N P P N P N P P P N P N N P P N P P N P N P N N P P P P P P N P N P N P P P N P P N N P N P P P N P N N N P P N P P N P N P N P N N P P P N P N P N P N P ...
output:
Q 0000000000011011011000100011101100111110011011100000100011011000110100001011000001001110000011000100100000110000111100010010001110000110000110011101011000111001010010000111101101010010001110000010101000100000010001000001011001110101010011001011001101001111011011101110111001110110000111001101101000...
result:
points 0.30444444440 0.3044444444 Output is correct (P=0.028545, F=191.5, Q=300.9) -> 27.40 points
Test #22:
score: 27.16
Acceptable Answer
time: 3396ms
memory: 3908kb
input:
1000 0.039856 300 P P P P P N P N P P P N P P P N N P P P N P P N P P P N P N P N P N P P N P P P P N N N N P P P N P N P N P N P P N P N P N P N P P N P N P N P P N P N P N P N P N P P P P P N P N P P N P N P N P N P P N P N P P P P P P N N P N P P N N P P P P N P N P N P N P P P P N P N N P P P N ...
output:
Q 0111110001110111011101110110111011110010100110001100101101000111100110100101100110001001011100110100000110010000001011110111001111011010010010100011111001011011100011010000100010010011011111000001001010011011110110111110011110011101000001100001101110110111101100100010000010000010001100100100011001...
result:
points 0.30177777780 0.3017777778 Output is correct (P=0.039856, F=246.3, Q=388.8) -> 27.16 points
Test #23:
score: 28.03
Acceptable Answer
time: 4927ms
memory: 3900kb
input:
1000 0.068648 300 P P P P P P N P N P N P P N P P N P N P P N N P P P N P P N P N N N P P N P P P P P N N N P N P P N P N N P N P P N P N P P N P P N N P P N P N P P P N N P P P P N P P N P P N P P N N P P P P P P N P P P N N P N P P P N N P N P N P P P N N P P N P N P N P P N P P N P P P N N P N P ...
output:
Q 1000111101010000010111011000010110111100011001011000000011010100000101110100000110101011111111001000110100011101101100101000101110000001101110001011000101111100010100011001101001101001101011001011110011000011110011010100001000111001011101011101100110100010001011010111000000001101000001110100010010...
result:
points 0.31144444440 0.3114444444 Output is correct (P=0.068648, F=366.2, Q=568.6) -> 28.03 points
Test #24:
score: 0
Time Limit Exceeded
input:
1000 0.104571 300 P P P P N P P P P N P N N N P P P N P N P P N P P N P N P P P P P N N N P P P P P P N N N N P N P N P P N P P P N P P N P N P N P N P P N P N P N P N P N P P N P N P P P P N P N P N P P P P P P N P P P N P P P N P P P N P P N N P P N P P N P N P P P P N P N N N P P N P N P P P P N ...
output:
Q 0000101110000001010000010010000011100000110100000010011001000001100110001111010000100000010001010110010100001100010010100001011101100001011100001010011001011000100100010001001111001000100011100000000000110100000011001000010010010110100101000000100110110100100000000001000000001000000010100100000011...