Submission #1292530

#TimeUsernameProblemLanguageResultExecution timeMemory
1292530dostsCOVID tests (CEOI24_covid)C++20
0 / 100
3 ms408 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;

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';
}

std::vector<bool> find_positive() {
    std::vector<bool> answer(N,0);
    int s = 5;
    vector<bool> test(N,0);
    for (int i = 0;i<N;i+=s) {
        int r = min(i+s-1,N-1);
        for (int j = i;j<=r;j++) {
            test[j] = 1;
        }
        int lst = i;
        while (lst <= r && test_students(test)) {
            int l = lst;
            int r = r;
            while (l<=r) {
                int m = (l+r) >> 1;
                for (int j = lst;j<=m;j++) if (!answer[j]) test[j] = 1;
                for (int j = m+1;j<=r;j++) test[j] = 0;
                if (test_students(test)) r = m-1;
                else l = m+1;
            }
            answer[l] = 1;
            lst = l+1;
            for (int j = i;j<=r;j++) test[j] = (j>=lst);
        }
        for (int j = i;j<=r;j++) {
            test[j] = 0;
        }
    }
    return answer;
}

int 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 'bool test_students(std::vector<bool>)':
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     scanf("%d %lf %d", &N, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...