답안 #1071402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071402 2024-08-23T07:10:49 Z jer033 COVID tests (CEOI24_covid) C++17
10 / 100
71 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)
{
    string sform = "Q=";
    sform.reserve(1005);
    for (int i=0; i<x; i++)
        sform+='0';
    for (int i=x; i<=y; i++)
        sform+='1';
    for (int i=y+1; i<1000; i++)
        sform+='0';
    sform+='\n';
    printf("%s", &sform);
    cout.flush();
    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 response = ask_query2(x, y);
    if (response==1)
    {
        if (x==y)
            answer[x] = 1;
        else
        {
            int z = (x+y)/2;
            range_query(x, z);
            range_query(z+1, y);
        }
        return 1;
    }
    return 0;
}

int main()
{
    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);
            else if (P < 0.05)
            {
                for (int i=1; i<=10; i++)
                    range_query(100*i-100, 100*i-1);
            }
            else if (P < 0.11)
            {
                for (int i=1; i<=50; i++)
                    range_query(20*i-20, 20*i-1);
            }
            else
            {
                for (int i=1; i<=100; i++)
                    range_query(10*i-10, 10*i-1);
            }
            bool L = report(answer);
            if (L==0)
                T = 0;
        }
    }
}

Compilation message

Main.cpp: In function 'bool ask_query2(int, int)':
Main.cpp:37:14: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} [-Wformat=]
   37 |     printf("%s", &sform);
      |             ~^   ~~~~~~
      |              |   |
      |              |   std::string* {aka std::__cxx11::basic_string<char>*}
      |              char*
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 344 KB Output is correct
2 Correct 49 ms 344 KB Output is correct
3 Correct 46 ms 344 KB Output is correct
4 Correct 50 ms 344 KB Output is correct
5 Correct 66 ms 344 KB Output is correct
6 Correct 47 ms 344 KB Output is correct
7 Correct 58 ms 344 KB Output is correct
8 Correct 48 ms 344 KB Output is correct
9 Correct 71 ms 344 KB Output is correct
10 Correct 50 ms 344 KB Output is correct
11 Correct 71 ms 344 KB Output is correct
12 Correct 39 ms 344 KB Output is correct
13 Correct 60 ms 344 KB Output is correct
14 Correct 47 ms 344 KB Output is correct
15 Correct 44 ms 344 KB Output is correct
16 Correct 42 ms 344 KB Output is correct
17 Correct 61 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -