Submission #1026347

#TimeUsernameProblemLanguageResultExecution timeMemory
102634712345678COVID tests (CEOI24_covid)C++17
93.69 / 100
1886 ms344 KiB
#include <cassert> #include <cstdio> #include <string> #include <vector> #include <bits/stdc++.h> 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'; } std::vector<bool> find_positive(int sz) { vector<bool> qrs(N), res(N); vector<int> vs(N); int a=0, b; while (a<N) { b=min(a+sz-1, N-1); for (int i=0; i<N; i++) qrs[i]=0; for (int i=a; i<=b; i++) qrs[i]=1; if (!test_students(qrs)) { a=b+1; continue; } int l=a, r=b; while (l<r) { int md=(l+r)/2; for (int i=0; i<N; i++) qrs[i]=0; for (int i=l; i<=md; i++) qrs[i]=1; if (test_students(qrs)) r=md; else l=md+1; } res[l]=1; a=l+1; } return res; } std::vector<bool> find_positive_brute_force() { std::vector<bool> answer(N); vector<bool> qrs(N); for (int i=0; i<N; i++) qrs[i]=1, answer[i]=test_students(qrs), qrs[i]=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; if (P==0.001) answer=find_positive(500); else if (P==0.005256) answer=find_positive(125); else if (P==0.011546) answer=find_positive(59); else if (P==0.028545) answer=find_positive(25); else if (P==0.039856) answer=find_positive(17); else if (P==0.068648) answer=find_positive(10); else if (P==0.104571) answer=find_positive(7); else if (P==0.158765) answer=find_positive(4); else if (P==0.2) answer=find_positive(4); else answer=find_positive_brute_force(); 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; } //PNPPN //0110011

Compilation message (stderr)

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