Submission #1134693

#TimeUsernameProblemLanguageResultExecution timeMemory
1134693saidponCOVID tests (CEOI24_covid)C++17
0 / 100
7050 ms408 KiB
#include "bits/stdc++.h"
#define int long long
#define pb push_back
using namespace std;

int N;

double P;

bool test_students(std::vector<bool> mask) {
    assert(mask.size() == (size_t)N);

    std::string mask_str(N, ' ');
    for (int i = 0; i < N; i++)
        mask_str[i] = mask[i] ? '1' : '0';

    printf("Q %s\n", mask_str.c_str());
    fflush(stdout);

    char answer;
    scanf(" %c", &answer);
    return answer == 'P';
}

vector<bool> find_positive() {
    vector<bool> answer(N), mask(N);
    int k = P * N, c = N / k;
    for (int i = 0; i < N; i += c) {
        int L = i, R = i + c - 1;
        auto check = [&](int r) {
            cout << "Q ";
            for (int j = 0; j < N; j++) {
                if (j >= L && j <= r) cout << 1;
                else cout << 0;
            }
            cout << endl;
            char x;
            cin >> x;
            if (x == 'P') return 1;
            return 0;
        };
        for (int j = L; j <= R;) {
            int l = j, r = R, ans = -1;
            if (!check(r)) break;
            while (r > l) {
                int m = l + r >> 1;
                if (check(m)) ans = m, r = m;
                else l = m + 1;
            }
            answer[ans] = 1, j = ans + 1;
        }
    }
    return answer;
}

signed main() {
    int T;
    scanf("%d %lf %d", &N, &P, &T);

    for (int i = 0; i < T; i++) {
        std::vector<bool> answer = find_positive();
        assert(answer.size() == (size_t)N);

        std::string answer_str(N, ' ');
        for (int j = 0; j < N; j++)
            answer_str[j] = answer[j] ? '1' : '0';

        printf("A %s\n", answer_str.c_str());
        fflush(stdout);

        char verdict;
        scanf(" %c", &verdict);
        if (verdict == 'W')
            exit(0);
    }

    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:58:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   58 |     scanf("%d %lf %d", &N, &P, &T);
      |            ~^          ~~
      |             |          |
      |             int*       long long int*
      |            %lld
Main.cpp:58:20: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   58 |     scanf("%d %lf %d", &N, &P, &T);
      |                   ~^           ~~
      |                    |           |
      |                    int*        long long int*
      |                   %lld
Main.cpp: In function 'bool test_students(std::vector<bool>)':
Main.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     scanf("%d %lf %d", &N, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...