QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#525306 | #9162. COVID tests | ANIG | 0 | 280ms | 19340kb | C++14 | 1.5kb | 2024-08-20 15:24:14 | 2024-08-20 15:24:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1005;
int n,t,rs[N],g[N][N];
double k,f[N][N],pw[N];
int gets(int l,int r){
cout<<"Q ";
for(int i=1;i<l;i++)putchar('0');
for(int i=l;i<=r;i++)putchar('1');
for(int i=r+1;i<=n;i++)putchar('0');
cout<<endl;
char x;
cin>>x;
return x=='P';
}
void solve(int l,int r,int a,int b){
// cout<<l<<" "<<r<<" "<<a<<" "<<b<<endl;
if(a==b){
rs[a]=1;
a=b+1;
l++;
if(l>r)return;
}
if(a>b){
int k=g[r-l+1][0];
if(gets(a,a+k-1)){
solve(l,r,a,a+k-1);
}else{
solve(a+k,r,a+k,a+k-1);
}
}else{
int k=g[r-l+1][b-a+1];
if(gets(a,a+k-1)){
solve(l,r,a,a+k-1);
}else{
solve(a+k,r,a+k,b);
}
}
}
void find_positive(){
memset(rs,0,sizeof(rs));
solve(1,n,1,0);
cout<<"A ";
for(int i=1;i<=n;i++)putchar(rs[i]+'0');
cout<<endl;
char c;
cin>>c;
}
signed main(){
cin>>n>>k>>t;
for(int i=1;i<=n;i++)pw[i]=pw[i-1]*(1-k);
for(int i=1;i<=n;i++){
for(int j=i;j>=0;j--){
f[i][j]=1e9;
if(j==0){
for(int k=1;k<=i;k++){
double ans=f[i-k][j]*pw[k]+f[i][k]*(1-pw[k])+1;
if(ans<f[i][j]){
g[i][j]=k;
f[i][j]=ans;
}
}
}else if(j==1)f[i][j]=f[i-1][0],g[i][j]=0;
else for(int k=1;k<j;k++){
double ks=(pw[k]-pw[j])/(1-pw[j]);
double ans=f[i-k][j-k]*ks+f[i][k]*(1-ks)+1;
if(ans<f[i][j]){
g[i][j]=k;
f[i][j]=ans;
}
}
}
}
while(t--)find_positive();
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 10
Accepted
time: 266ms
memory: 18988kb
input:
1000 0.789673 1 P P P N 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 N 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 N 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 N 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 ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 273ms
memory: 19340kb
input:
1000 0.686378 1 P N N P N N P P P N P P N P P P P P P P P P N P P P P P N P P P P N P P P N P P P P N P N 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 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 N P P P P N P N P P P N P N P P P P P P P P P N N P P P P P P P N N P P ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 280ms
memory: 19080kb
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 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 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 N 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 ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 0
Time Limit Exceeded
input:
1000 0.669578 1 P P P P P N 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 P P N P P P P P P N P P P N P N P P P N P P P N 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 N P P P P P N P P N P P P P N P P P N P N 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 N P P P N P ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #18:
score: 0
Time Limit Exceeded
input:
1000 0.001 300 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...