답안 #1038051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038051 2024-07-29T12:30:12 Z ttamx COVID tests (CEOI24_covid) C++17
64.22 / 100
1388 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,t,k;
double p;
string ans;

int ask(int l,int r){
    string s(n,'0');
    for(int i=l;i<=r;i++)s[i]='1';
    cout << "Q " << s << endl;
    char res;
    cin >> res;
    return res=='P';
}

void solve(int l,int r){
    if(l==r)return void(ans[l]='1');
    int m=(l+r)/2;
    bool found=false;
    if(rng()&1){
        if(ask(l,m)){
            solve(l,m);
            found=true;
        }
        if(!found||ask(m+1,r)){
            solve(m+1,r);
        }
    }else{
        if(ask(m+1,r)){
            solve(m+1,r);
            found=true;
        }
        if(!found||ask(l,m)){
            solve(l,m);
        }
    }
}

void runcase(){
    ans=string(n,'0');
    for(int l=0,r=k-1;l<n;l+=k,r+=k){
        r=min(r,n-1);
        if(ask(l,r))solve(l,r);
    }
    cout << "A " << ans << endl;
    string s;
    cin >> s;
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> p >> t;
    double q=1-p,r=q;
    k=1;
    while(r>0.5&&k<n){
        r*=q;
        k++;
    }
    while(t--)runcase();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 7 ms 344 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 6 ms 344 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB Output is correct (P=0.001, F=15.1, Q=14.1) -> 90.00 points
2 Correct 89 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=58.0) -> 58.44 points
3 Correct 222 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=110.0) -> 55.00 points
4 Correct 401 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=223.1) -> 54.22 points
5 Correct 507 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=283.2) -> 56.28 points
6 Correct 703 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=413.9) -> 59.17 points
7 Correct 916 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=536.9) -> 65.21 points
8 Correct 1193 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=688.4) -> 68.78 points
9 Correct 1388 ms 344 KB Output is correct (P=0.2, F=731.4, Q=769.1) -> 74.62 points