답안 #1071675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071675 2024-08-23T09:51:49 Z jer033 COVID tests (CEOI24_covid) C++17
54.96 / 100
5204 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

vector<bool> answer(1000, 0);

void answer_clear()
{
    for (int i=0; i<1000; i++)
        answer[i] = 0;
}

bool ask_query(vector<bool> a)
{
    cout << "Q ";
    for (int i=0; i<1000; i++)
        cout << a[i];
    cout << '\n';
    cout.flush();
    char x;
    cin >> x;
    if (x=='P')
        return 1;
    return 0;
}

bool ask_query2(int x, int y)
{
    cout << "Q ";
    for (int i=0; i<x; i++)
        cout << '0';
    for (int i=x; i<=y; i++)
        cout << '1';
    for (int i=y+1; i<1000; i++)
        cout << '0';
    cout << endl;
    char k;
    cin >> k;
    if (k=='P')
        return 1;
    return 0;
}

bool report(vector<bool> a)
{
    cout << "A ";
    for (int i=0; i<1000; i++)
        cout << a[i];
    cout << '\n';
    cout.flush();
    char x;
    cin >> x;
    if (x=='C')
        return 1;
    return 0;
}

long double prob;

bool range_query(int x, int y, bool known)
{
    bool response;
    if (known==1)
        response = 1;
    else
        response = ask_query2(x, y);
    if (response==1)
    {
        if (x==y)
            answer[x] = 1;
        else
        {
            int z = (2*x+3*y)/5;
            bool a = range_query(x, z, 0);
            if (a==0)
                range_query(z+1, y, 1);
            else
                range_query(z+1, y, 0);
        }
        return 1;
    }
    return 0;
}

void work(int m)
{
    int curr = 0;
    bool go_on = 1;
    while (go_on)
    {
        range_query(curr, min(curr+m-1, 999), 0);
        if ((curr+m-1)>=999)
            go_on = 0;
        curr+=m;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    int N, T;
    long double P;
    cin >> N >> P >> T;
    if (T==1)
    {
        while (T--)
        {
            vector<bool> query(N, 0);
            vector<bool> ans(N, 0);
            for (int i=0; i<N; i++)
            {
                query[i] = 1;
                ans[i] = ask_query(query);
                query[i] = 0;
            }
            bool L = report(ans);
            if (L==0)
                T = 0;
        }
    }
    else
    {
        prob = P;
        while (T--)
        {
            answer_clear();
            if (P < 0.005)
                work(1000);
            else if (P < 0.01)
                work(334);
            else if (P < 0.02)
                work(45);
            else if (P < 0.03)
                work(18);
            else if (P < 0.05)
                work(12);
            else if (P < 0.10)
                work(8);
            else if (P < 0.15)
                work(5);
            else if (P < 0.19)
                work(4);
            else
                work(3);
            bool L = report(answer);
            if (L==0)
                T = 0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 344 KB Output is correct
2 Correct 34 ms 344 KB Output is correct
3 Correct 38 ms 344 KB Output is correct
4 Correct 33 ms 344 KB Output is correct
5 Correct 37 ms 344 KB Output is correct
6 Correct 41 ms 344 KB Output is correct
7 Correct 33 ms 344 KB Output is correct
8 Correct 34 ms 344 KB Output is correct
9 Correct 37 ms 344 KB Output is correct
10 Correct 36 ms 344 KB Output is correct
11 Correct 37 ms 344 KB Output is correct
12 Correct 33 ms 344 KB Output is correct
13 Correct 35 ms 344 KB Output is correct
14 Correct 32 ms 344 KB Output is correct
15 Correct 48 ms 344 KB Output is correct
16 Correct 33 ms 344 KB Output is correct
17 Correct 41 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 344 KB Output is correct (P=0.001, F=15.1, Q=15.0) -> 90.00 points
2 Correct 408 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=63.9) -> 44.96 points
3 Correct 802 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=117.4) -> 46.19 points
4 Correct 1487 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=231.5) -> 49.03 points
5 Correct 1929 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=294.1) -> 50.67 points
6 Correct 2805 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=435.7) -> 51.16 points
7 Correct 3762 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=559.9) -> 57.40 points
8 Correct 4306 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=671.0) -> 75.02 points
9 Correct 5204 ms 344 KB Output is correct (P=0.2, F=731.4, Q=804.1) -> 64.40 points