QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523820 | #9162. COVID tests | zzafanti | 0 | 0ms | 0kb | C++23 | 1.4kb | 2024-08-18 18:53:19 | 2024-08-18 18:53:19 |
answer
#include<bits/stdc++.h>
using namespace std;
using R=double;
template<class A,class B>
bool chkmin(A &t,B x){ return t>x?t=x,1:0; }
int N,T;
R P;
vector<R> dp;
vector<int> from;
vector<int> res,p;
mt19937 gen(time(0));
int query(int l,int r){
cout<<"Q ";
for(int i=1; i<=N; i++){
if(l<=p[i]&&p[i]<=r) cout<<1;
else cout<<0;
}
cout<<endl;
char t;
cin>>t;
return t=='P';
}
void construct(int l,int r){
if(l>r) return;
if(l==r){
res[p[l]]=query(l,r);
return ;
}
int len=from[r-l+1];
assert(len);
int pt=query(r-len+1,r);
if(pt){
if(len==1){
res[p[r]]=1;
}
else{
construct(r-len+1,r);
}
}
construct(l,r-len);
}
void solve(){
shuffle(p.begin()+1,p.end(),gen);
res=vector<int>(N+1);
if(query(1,N)) construct(1,N);
cout<<"A ";
for(int i=1; i<=N; i++){
cout<<res[i];
}
cout<<endl;
char res;
cin>>res;
assert(res=='C');
}
int main(){
cin>>N>>P>>T;
dp.assign(N+1,1e9);
from.resize(N+1);
dp[0]=0,dp[1]=1;
from[1]=1;
for(int i=1; i<=N; i++){
R coef=1;
for(int j=1; j<i; j++){
coef=coef*(1-P);
if(chkmin(dp[i],dp[i-j]+1+(dp[j])*(1-coef))){
from[i]=j;
}
}
//cerr<<i<<' '<<from[i]<<endl;
//cerr<<i<<' '<<dp[i]<<endl;
}
p=vector<int>(N+1);
for(int i=1; i<=N; i++) p[i]=i;
while(T--) solve();
return 0;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
1000 0.789673 1 P P P P P P P N P P P P P P N P P P N P P P P P N P P P P P P P N P N P P P P N P N P P P N 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 N P P P P P P P P N N N N P P P P P N N 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 N P P P P P N P N N P N P P P P N P P P N P ...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
Subtask #2:
score: 0
Runtime Error
Test #18:
score: 0
Runtime Error
input:
1000 0.001 300 N C P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P 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 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...