QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#499725 | #9162. COVID tests | kshitij_sodani# | 0 | 0ms | 0kb | C++17 | 2.5kb | 2024-07-31 18:06:37 | 2024-07-31 18:06:41 |
answer
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
pair<int,int> 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(vector<int> yy){
if(yy.size()==0){
return;
}
if(yy.size()==1){
if(query(yy)==1){
ans[yy[0]]=1;
}
return;
}
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
int x=dp[yy.size()].b;
shuffle(yy.begin(),yy.end(),rng);
/* vector<int> rr;
vector<int> ll;
for(int j=0;j<yy.size();j++){
if(j<x){
ll.pb(yy[j]);
}
else{
rr.pb(yy[j]);
}
}
if(query(ll)==1){
if(ll.size()==1){
ans[ll[0]]=1;
}
else{
solve(ll);
}
}
if(rr.size()){
solve(rr);
}
return ;*/
int ok=0;
//cout<<r-l+1<<":::"<<x<<endl;
vector<int> zz;
for(int j=0;j<yy.size();j+=x){
int k=min(j+x-1,(int)yy.size()-1);
vector<int> xx;
for(int ii=j;ii<=k;ii++){
xx.pb(yy[ii]);
}
if(query(xx)==1){
ok=1;
if(j==k){
ans[xx[0]]=1;
}
else{
for(auto jj:xx){
zz.pb(jj);
}
//solve(j,k,xx);
}
}
}
solve(zz);
}
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={1+dp[i-j].a,j};
cur.a+=round(dp[j].a*(1-pre[j]));
*/
pair<llo,llo> cur={(i+j-1)/j,j};
llo xx=j*round((1-pre[j])*((i+j-1)/j));
cur.a+=dp[xx].a;
/*
llo xx=1-pre[j];
cur.a+=xx*(i/j);
long double cot=0;
*/
/*if(i%j!=0){
llo xx=(1-pre[i%j]);
cur.a+=xx;
}*/
if(cur.a<dp[i].a){//-0.0001){
dp[i]=cur;
}
}
}
/*for(int i=1;i<=20;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(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;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
1000 0.789673 1
output:
result:
Subtask #2:
score: 0
Memory Limit Exceeded
Test #18:
score: 0
Memory Limit Exceeded
input:
1000 0.001 300 N N C N P N P N P P N N P N P P N N P N P N P C P N P N P P N P N P P 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 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 P P P P P P P P...
output:
Q 0000001000001001010110111000100011001000001000100000100101000011111110000000011111110001111100110011010010001110101110110011000011101001111010101110110101110000110011111110111001001110111000100010010010100000010111111011010110001110010010000110101100111100111000010001001011000111001010101011010001...