Submission #1237213

#TimeUsernameProblemLanguageResultExecution timeMemory
1237213The_SamuraiCOVID tests (CEOI24_covid)C++20
54.09 / 100
6790 ms628 KiB
#include "bits/stdc++.h" using namespace std; /// You may use: // The number of students int n; // The probability any given student is positive double P; // This function performs a test on a subset of samples. // Its argument is a vector of Booleans of length N, // where the i-th element is true if the i-th sample should be added to the mix. // It returns true if (and only if) at least one of the samples in the mix is positive. map<vector<bool>, bool> mp; bool test_students(std::vector<bool> mask) { if (mp.count(mask)) return mp[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 mp[mask] = (answer == 'P'); } int f(int l, int r) { int best = -1, start = l; while (l <= r) { int mid = (l + r) >> 1; vector<bool> shit(n); for (int i = start; i <= mid; i++) shit[i] = true; if (test_students(shit)) { best = mid; r = mid - 1; } else { l = mid + 1; } } return best; } std::vector<bool> find_positive() { mp.clear(); int exp = n * P, best = 1e9; for (int ln = 1; ln <= n; ln++) { int now = (n + ln - 1) / ln; now += log2(ln) * max(now, exp); best = min(best, now); } vector<bool> ans(n); for (int ln = 1; ln <= n; ln++) { int now = (n + ln - 1) / ln; now += log2(ln) * max(now, exp); if (now != best) continue; for (int i = 0; i * ln < n; i++) { int l = i * ln, r = min(n - 1, (i + 1) * ln - 1); vector<bool> shit(n); for (int j = l; j <= r; j++) shit[j] = true; if (!test_students(shit)) continue; while (l <= r) { int best = f(l, r); if (best == -1) break; ans[best] = true; l = best + 1; } } break; } return ans; } int main() { int T; scanf("%d %lf %d", &n, &P, &T); // You may perform any extra initialization here. 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:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:82:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |     scanf("%d %lf %d", &n, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:98:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...