Submission #1212003

#TimeUsernameProblemLanguageResultExecution timeMemory
1212003yanbCOVID tests (CEOI24_covid)C++20
0 / 100
7004 ms412 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int N; double P; map<int, int> BM; 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); } } } vector<bool> find_positive() { vector<bool> answer(N); int Block = BM[P * 1000000]; 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); BM[200000] = 2; BM[158765] = 4; BM[104571] = 8; BM[68648] = 16; BM[39856] = 32; BM[28545] = 64; BM[11546] = 128; BM[5256] = 256; BM[100] = 512; 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:61:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   61 |     scanf("%d %lf %d", &N, &P, &T);
      |            ~^          ~~
      |             |          |
      |             int*       long long int*
      |            %lld
Main.cpp:61:20: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   61 |     scanf("%d %lf %d", &N, &P, &T);
      |                   ~^           ~~
      |                    |           |
      |                    int*        long long int*
      |                   %lld
Main.cpp: In function 'bool test_students(std::vector<bool>)':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%d %lf %d", &N, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:85:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...