Submission #1044247

# Submission time Handle Problem Language Result Execution time Memory
1044247 2024-08-05T08:19:01 Z gagik_2007 COVID tests (CEOI24_covid) C++17
82.74 / 100
7000 ms 2780 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ff first
#define ss second

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=5007;
ll n,m,k;
double p;
map<string, int>d;
int DIV=100;

bool query(string s){
    if(d[s]){
        if(d[s]==1){
            return false;
        }
        return true;
    }
    cout<<"Q "<<s<<endl;
    char res;
    cin>>res;
    bool ress=false;
    if(res=='P'){
        ress=true;
    }
    d[s]=ress+1;
    return ress;
}

bool queryRange(int l, int r){
    string s="";
    for(int i=0;i<l;i++){
        s+='0';
    }
    for(int i=l;i<=r;i++){
        s+='1';
    }
    for(int i=r+1;i<n;i++){
        s+='0';
    }
    return query(s);
}

int findNextPositive(int from, int to){
    if(!queryRange(from, to)){
        return to+1;
    }
    int l=from;
    int r=to;
    while(l<r){
        int mid=(l+r)/2;
        if(queryRange(l, mid)){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    return l;
}

void clear(){
    d.clear();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("Binput.txt","r",stdin);
    // freopen("Boutput.txt","w",stdout);
    cin>>n>>p>>ttt;
    if(p<0.005){
        DIV=1;
    }
    else if(p<0.02){
        DIV=10;
    }
    else if(p<0.03){
        DIV=33;
    }
    else if(p<0.05){
        DIV=50;
    }
    else if(p<0.1){
        DIV=90;
    }
    else if(p<0.15){
        DIV=125;
    }
    else if(p<0.18){
        DIV=250;
    }
    else{
        DIV=300;
    }
    while(ttt--){
        clear();
        string ans="";
        for(int i=0;i<n;i++){
            ans+='0';
        }
        for(int fromm=0;fromm<n;fromm+=n/DIV){
            int from=fromm;
            int to=min(from+n/DIV-1,n-1);
            while(true){
                int ind=findNextPositive(from,to);
                if(ind==to+1){
                    break;
                }
                from=ind+1;
                ans[ind]='1';
                if(from>=to+1)break;
            }
        }
        cout<<"A "<<ans<<endl;
        char c;
        cin>>c;
        if(c=='W'){
            return 0;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 7019 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2124 KB Output is correct
2 Correct 14 ms 2136 KB Output is correct
3 Correct 12 ms 2356 KB Output is correct
4 Correct 11 ms 2136 KB Output is correct
5 Correct 14 ms 2384 KB Output is correct
6 Correct 16 ms 2356 KB Output is correct
7 Correct 10 ms 1880 KB Output is correct
8 Correct 11 ms 1472 KB Output is correct
9 Correct 13 ms 2052 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 8 ms 1500 KB Output is correct
12 Correct 8 ms 1536 KB Output is correct
13 Correct 11 ms 1680 KB Output is correct
14 Correct 8 ms 1836 KB Output is correct
15 Correct 10 ms 1616 KB Output is correct
16 Correct 18 ms 2780 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 508 KB Output is correct (P=0.001, F=15.1, Q=10.7) -> 90.00 points
2 Correct 120 ms 776 KB Output is correct (P=0.005256, F=51.1, Q=48.3) -> 90.00 points
3 Correct 233 ms 828 KB Output is correct (P=0.011546, F=94.9, Q=94.2) -> 90.00 points
4 Correct 502 ms 1316 KB Output is correct (P=0.028545, F=191.5, Q=194.9) -> 84.03 points
5 Correct 680 ms 1656 KB Output is correct (P=0.039856, F=246.3, Q=255.5) -> 78.30 points
6 Correct 901 ms 1708 KB Output is correct (P=0.068648, F=366.2, Q=384.0) -> 75.35 points
7 Correct 1404 ms 2024 KB Output is correct (P=0.104571, F=490.3, Q=507.4) -> 78.98 points
8 Correct 1847 ms 2660 KB Output is correct (P=0.158765, F=639.1, Q=655.6) -> 81.58 points
9 Correct 2209 ms 2372 KB Output is correct (P=0.2, F=731.4, Q=774.8) -> 72.74 points