Submission #1038637

# Submission time Handle Problem Language Result Execution time Memory
1038637 2024-07-30T04:36:32 Z Warinchai COVID tests (CEOI24_covid) C++14
0 / 100
13 ms 344 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
int n,t;
double p;
int use=0;
int ask(string v){
    //use++;
    cout<<"Q ";
    cout<<v;
    cout<<endl;
    //cerr<<"input:"<<endl;
    char ans;
    cin>>ans;
    //cerr<<ans<<endl;
    return ans=='P'?1:0;
}
string temp;
string ans;
void fans(int st,int en){
    //cerr<<st<<" "<<en<<endl;
    if(st>=en)return;
    int m=(st+en)/2;
    for(int i=st;i<=m;i++)temp[i]='1';
    bool tans;tans=ask(temp);
    for(int i=st;i<=m;i++)temp[i]='0';
    if(tans){
        if(st==m)ans[st]=1;
        else fans(st,m);
    }
    for(int i=m+1;i<=en;i++)temp[i]='1';
    tans=ask(temp);
    for(int i=m+1;i<=en;i++)temp[i]='0';
    if(tans){
        if(m+1==en)ans[en]='1';
        else fans(m+1,en);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>p>>t;
    temp=string(n,'0');
    while(t--){
        //cerr<<"work"<<endl;
        ans=string(n,'0');
        use=0;
        int prob=p*n;
        int div=n/prob;
        //cout<<"prob:"<<prob<<endl;
        /*for(int i=1;i<=prob;i++){
            string t(n,'0');
            for(int j=div*(i-1);j<=(i==prob?n-1:div*i-1);j++)t[j]=1;
            if(ask(t))fans(div*(i-1),i==prob?n-1:div*i-1);
        }*/
        fans(0,n-1);
        cout<<"A ";
        cout<<ans;
        cout<<endl;
        char res;
        cin>>res;
        //cerr<<"use:"<<use<<endl;
        if(res=='W')break;
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:51:13: warning: unused variable 'div' [-Wunused-variable]
   51 |         int div=n/prob;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 344 KB Protocol violation
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 340 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -