Submission #1071471

# Submission time Handle Problem Language Result Execution time Memory
1071471 2024-08-23T07:37:36 Z jer033 COVID tests (CEOI24_covid) C++17
55.96 / 100
6366 ms 596 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;
}

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 = (x+y)/2;
            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;
}

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
    {
        while (T--)
        {
            answer_clear();
            if (P < 0.01)
                range_query(0, 999, 0);
            else if (P < 0.05)
            {
                for (int i=1; i<=20; i++)
                    range_query(50*i-50, 50*i-1, 0);
            }
            else if (P < 0.11)
            {
                for (int i=1; i<=50; i++)
                    range_query(20*i-20, 20*i-1, 0);
            }
            else
            {
                for (int i=1; i<=100; i++)
                    range_query(10*i-10, 10*i-1, 0);
            }
            bool L = report(answer);
            if (L==0)
                T = 0;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 344 KB Output is correct
2 Correct 33 ms 344 KB Output is correct
3 Correct 36 ms 344 KB Output is correct
4 Correct 51 ms 344 KB Output is correct
5 Correct 35 ms 344 KB Output is correct
6 Correct 54 ms 344 KB Output is correct
7 Correct 50 ms 344 KB Output is correct
8 Correct 35 ms 344 KB Output is correct
9 Correct 33 ms 344 KB Output is correct
10 Correct 33 ms 344 KB Output is correct
11 Correct 42 ms 344 KB Output is correct
12 Correct 43 ms 344 KB Output is correct
13 Correct 56 ms 344 KB Output is correct
14 Correct 58 ms 344 KB Output is correct
15 Correct 52 ms 344 KB Output is correct
16 Correct 36 ms 344 KB Output is correct
17 Correct 44 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 344 KB Output is correct (P=0.001, F=15.1, Q=13.9) -> 90.00 points
2 Correct 432 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=61.5) -> 49.61 points
3 Correct 876 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=112.9) -> 51.17 points
4 Correct 1685 ms 596 KB Output is correct (P=0.028545, F=191.5, Q=233.9) -> 47.73 points
5 Correct 2190 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=305.3) -> 45.96 points
6 Correct 2972 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=439.5) -> 49.98 points
7 Correct 4030 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=597.0) -> 48.12 points
8 Correct 5033 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=752.3) -> 52.68 points
9 Correct 6366 ms 344 KB Output is correct (P=0.2, F=731.4, Q=885.4) -> 48.85 points