Submission #1042096

# Submission time Handle Problem Language Result Execution time Memory
1042096 2024-08-02T14:28:42 Z Warinchai COVID tests (CEOI24_covid) C++14
13.01 / 100
3589 ms 7996 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){
    en=min(n-1,en);
    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);
    freq=max(n,freq);
    int mx=0;
    while((1<<mx)<freq)mx++;
    mx--;
    mx=min(9,mx);
    mx=max(0,mx);
    while(t--){
        //cerr<<"work"<<endl;
        mp.clear();
        int cur=-1;
        string ans=string(n,'0');
        int og=cur;
        while(cur<n-1){
            int nmx=0;
            int rmx=0;
            if(cur+freq>=n){
                while(cur+(1<<nmx)<n)nmx++;
                nmx--;
                rmx=(1<<nmx);
            }else{
                nmx=mx;
                rmx=freq;
            }
            //cout<<nmx<<endl;
            if(ask(cur+1,cur+rmx)){
                for(int i=nmx;i>=0;i--)if(!ask(cur+1,cur+(1<<i)))cur=cur+(1<<i);
                cur++;
                ans[cur]='1';
            }else{
                cur=cur+rmx;
                continue;
            }
        }
        //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;
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:44:13: warning: unused variable 'og' [-Wunused-variable]
   44 |         int og=cur;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 7996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 600 KB Output is correct (P=0.001, F=15.1, Q=12.7) -> 90.00 points
2 Correct 94 ms 784 KB Output is correct (P=0.005256, F=51.1, Q=53.1) -> 77.82 points
3 Correct 210 ms 864 KB Output is correct (P=0.011546, F=94.9, Q=110.5) -> 54.30 points
4 Correct 470 ms 1516 KB Output is correct (P=0.028545, F=191.5, Q=263.5) -> 35.94 points
5 Correct 673 ms 1520 KB Output is correct (P=0.039856, F=246.3, Q=368.7) -> 30.12 points
6 Correct 1161 ms 1928 KB Output is correct (P=0.068648, F=366.2, Q=628.7) -> 23.27 points
7 Correct 1821 ms 2340 KB Output is correct (P=0.104571, F=490.3, Q=951.6) -> 18.89 points
8 Correct 2734 ms 2716 KB Output is correct (P=0.158765, F=639.1, Q=1425.7) -> 15.19 points
9 Correct 3589 ms 3380 KB Output is correct (P=0.2, F=731.4, Q=1813.4) -> 13.01 points