Submission #1134697

#TimeUsernameProblemLanguageResultExecution timeMemory
1134697saidponCOVID tests (CEOI24_covid)C++17
0 / 100
13 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) { for (int j = 0; j < N; j++) mask[j] = (j >= L && j <= r); return test_students(mask); }; for (int j = L; j <= R;) { int l = j, r = R, ans = R; 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:50:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   50 |     scanf("%d %lf %d", &N, &P, &T);
      |            ~^          ~~
      |             |          |
      |             int*       long long int*
      |            %lld
Main.cpp:50:20: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   50 |     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:50:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     scanf("%d %lf %d", &N, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...