Submission #1212016

#TimeUsernameProblemLanguageResultExecution timeMemory
1212016yanbCOVID tests (CEOI24_covid)C++20
39.10 / 100
1014 ms408 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int N, Block; double P; bool test_students(vector<bool> mask) { assert(mask.size() == (size_t)N); 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'; } bool query(int l, int r) { vector<bool> mask(N); for (int i = l; i <= r; i++) mask[i] = 1; return test_students(mask); } void dnc(vector<bool> &ans, int l, int r) { if (l == r) { ans[l] = 1; } else { int md = (l + r) / 2; if (query(l, md)) { dnc(ans, l, md); if (query(md + 1, r)) dnc(ans, md + 1, r); } else { dnc(ans, md + 1, r); } } } int get_block() { int l = 0, r = N; while (r - l > 1) { int md = (r + l) / 2; if (pow(1.0 - P, md) >= 0.5) { l = md; } else { r = md; } } return r; } vector<bool> find_positive() { vector<bool> answer(N); for (int l = 0; l < N; l += Block) { if (query(l, min(l + Block, N) - 1)) dnc(answer, l, min(l + Block, N) - 1); } return answer; } signed main() { int T; scanf("%d %lf %d", &N, &P, &T); Block = 40.0 / P;//get_block(); for (int i = 0; i < T; i++) { vector<bool> answer = find_positive(); assert(answer.size() == (size_t)N); 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:70:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   70 |     scanf("%d %lf %d", &N, &P, &T);
      |            ~^          ~~
      |             |          |
      |             int*       long long int*
      |            %lld
Main.cpp:70:20: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   70 |     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:70:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |     scanf("%d %lf %d", &N, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:86:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...