Submission #1042045

# Submission time Handle Problem Language Result Execution time Memory
1042045 2024-08-02T13:12:44 Z Warinchai COVID tests (CEOI24_covid) C++14
0 / 100
7 ms 3132 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
int n,t;
double p;
int use=0;
map<string,int>mp;
int ask(string v){
    if(mp[v]!=0)return mp[v]-1;
    //use++;
    cout<<"Q ";
    cout<<v;
    cout<<endl;
    //cerr<<"input:"<<endl;
    char ans;
    cin>>ans;
    //cerr<<ans<<endl;
    return (mp[v]=(ans=='P'?1:0)+1)-1;
}
int ask(int st,int en){
    assert(st>=0&&en<=n-1);
    string temp(n,'0');
    for(int i=st;i<=en;i++)temp[i]='1';
    return ask(temp);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>p>>t;
    int freq=n/(p*n);
    int mx=0;
    while((1<<mx)<freq)mx++;
    mx=min(9,mx);
    while(t--){
        //cerr<<"work"<<endl;
        int cur=-1;
        string ans=string(n,'0');
        while(cur<n-1){
            int nmx=0;
            if(cur+(1<<mx)>=n){
                while(cur+(1<<nmx)<n)nmx++;
                nmx--;
            }else{
                nmx=mx;
            }
            if(ask(cur+1,cur+(1<<nmx))){
                for(int i=nmx-1;i>=0;i--)if(!ask(cur+1,cur+(1<<i)))cur=cur+(1<<i);
                cur++;
                ans[cur]='1';
            }else{
                int nw=nmx+1;
                while(cur+(1<<nw)<n&&ask(cur+1,cur+(1<<nw))==0){
                    nw++;
                }
                if(cur+(1<<nw)>=n){
                    if(!ask(cur+1,n-1))break;
                    for(int i=nw-1;i>=0;i--)if(!ask(cur+1,cur+(1<<i)))cur=cur+(1<<i);
                    cur++;
                    ans[cur]='1';
                }else{
                    for(int i=nw-1;i>=0;i--)if(!ask(cur+1,cur+(1<<i)))cur=cur+(1<<i);
                    cur++;
                    ans[cur]='1';
                }
            }
        }
        string x=ans;
        for(auto &a:x){
            if(a=='1')a='0';
            else a='1';
        }
        //cout<<x<<endl;
        //cout<<ask(x)<<endl;
        //assert(ask(x)==0);
        cout<<"A ";
        cout<<ans;
        cout<<endl;
        char res;
        cin>>res;
        //cerr<<"use:"<<use<<endl;
        if(res=='W')break;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1368 KB Output is correct
2 Correct 7 ms 1568 KB Output is correct
3 Correct 6 ms 1368 KB Output is correct
4 Correct 7 ms 1348 KB Output is correct
5 Correct 5 ms 1572 KB Output is correct
6 Correct 6 ms 1592 KB Output is correct
7 Correct 7 ms 1368 KB Output is correct
8 Correct 6 ms 1588 KB Output is correct
9 Correct 6 ms 1484 KB Output is correct
10 Correct 4 ms 1112 KB Output is correct
11 Correct 6 ms 1560 KB Output is correct
12 Correct 7 ms 1368 KB Output is correct
13 Runtime error 6 ms 3132 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -