답안 #1073435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073435 2024-08-24T14:45:36 Z jer033 COVID tests (CEOI24_covid) C++17
88.41 / 100
5224 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;
}

long double prob;

int range_first(int x, int y, bool known)
{
    if (x>y)
        return -5;
    bool response;
    if (known)
        response = 1;
    else
        response = ask_query2(x, y);
    
    if (response == 0)
        return -5;
    if (x==y)
    {
        answer[x] = 1;
        return x;
    }
    int z = (x+y)/2;
    int k = range_first(x, z, 0);
    if (k!=-5)
        return k;
    return range_first(z+1, y, 1);
}

void range_query(int x, int y, int m)
{
    int currx = x;
    int curry = y;
    while (currx!=-4)
    {
        currx = range_first(currx, curry, 0);
        currx++;
        if (currx!=-4)
        {
            curry = currx+m-1;
            curry = min(999, curry);
        }
    }
    if (curry!=999)
    {
        currx = curry+1;
        curry = currx+m-1;
        curry = min(999, curry);
        range_query(currx, curry, m);
    }
}

void work(int m)
{
    //int curr = 0;
    range_query(0, m-1, m);
    /*bool go_on = 1;
    while (go_on)
    {
        range_query(curr, min(curr+m-1, 999), m);
        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--)
        {
            work(1);
            bool L = report(answer);
            if (L==0)
                T = 0;
        }
    }
    else
    {
        prob = P;
        while (T--)
        {
            answer_clear();
            if (P < 0.005)
                work(1000);
            else if (P < 0.01)
                work(200);
            else if (P < 0.02)
                work(125);
            else if (P < 0.03)
                work(35);
            else if (P < 0.05)
                work(32);
            else if (P < 0.10)
                work(16);
            else if (P < 0.15)
                work(6);
            else if (P < 0.19)
                work(4);
            else
                work(4);
            bool L = report(answer);
            if (L==0)
                T = 0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 596 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 19 ms 344 KB Output is correct
4 Correct 19 ms 344 KB Output is correct
5 Correct 20 ms 344 KB Output is correct
6 Correct 27 ms 344 KB Output is correct
7 Correct 26 ms 344 KB Output is correct
8 Correct 23 ms 344 KB Output is correct
9 Correct 19 ms 344 KB Output is correct
10 Correct 19 ms 344 KB Output is correct
11 Correct 20 ms 344 KB Output is correct
12 Correct 20 ms 344 KB Output is correct
13 Correct 27 ms 344 KB Output is correct
14 Correct 24 ms 344 KB Output is correct
15 Correct 22 ms 344 KB Output is correct
16 Correct 19 ms 344 KB Output is correct
17 Correct 30 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 344 KB Output is correct (P=0.001, F=15.1, Q=10.7) -> 90.00 points
2 Correct 345 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=47.3) -> 90.00 points
3 Correct 666 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=94.6) -> 90.00 points
4 Correct 1293 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=193.0) -> 87.27 points
5 Correct 1774 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=255.4) -> 78.41 points
6 Correct 2667 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=377.6) -> 80.03 points
7 Correct 3277 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=499.5) -> 83.72 points
8 Correct 4540 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=633.1) -> 90.00 points
9 Correct 5224 ms 344 KB Output is correct (P=0.2, F=731.4, Q=740.9) -> 85.55 points