# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044485 | 2024-08-05T10:08:22 Z | Tsovak | COVID tests (CEOI24_covid) | C++17 | 30 ms | 600 KB |
// -------------------- Includes -------------------- // #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <iostream> #include <iomanip> #include <cstdio> #include <stdio.h> #include <cstdlib> #include <stdlib.h> #include <array> #include <string> #include <cstring> #include <algorithm> #include <cmath> #include <math.h> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <vector> #include <stack> #include <queue> #include <deque> #include <bitset> #include <list> #include <iterator> #include <numeric> #include <complex> #include <tuple> #include <utility> #include <cassert> #include <assert.h> #include <climits> #include <limits.h> #include <ctime> #include <time.h> #include <random> #include <chrono> #include <fstream> using namespace std; // -------------------- Typedefs -------------------- // typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; // -------------------- Defines -------------------- // #define pr pair #define mpr make_pair #define ff first #define ss second #define mset multiset #define mmap multimap #define uset unordered_set #define umap unordered_map #define umset unordered_multiset #define ummap unordered_multimap #define pqueue priority_queue #define sz(x) (int((x).size())) #define len(x) (int((x).length())) #define all(x) (x).begin(), (x).end() #define clr(x) (x).clear() #define ft front #define bk back #define pf push_front #define pb push_back #define popf pop_front #define popb pop_back #define lb lower_bound #define ub upper_bound #define bs binary_search // -------------------- Constants -------------------- // const int MAX = int(1e9 + 5); const ll MAXL = ll(1e18 + 5); const ll MOD = ll(1e9 + 7); const ll MOD2 = ll(998244353); // -------------------- Solution -------------------- // /// 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. 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'; } /// You should implement: // This function will be called once for each test instance. // It should use test_students to determine which samples are positive. // It must return a vector of Booleans of length N, // where the i-th element is true if and only if the i-th sample is positive. vector<bool> ans; void calc(int tl, int tr) { //cout << tl << ' ' << tr << "\n"; if (tl == tr) { ans.pb(1); return; } int m = (tl + tr) / 2; vector<bool> msk(N, 0); for (int i = tl; i <= m; i++) msk[i - 1] = 1; if (test_students(msk)) calc(tl, m); else for (int i = tl; i <= m; i++) ans.pb(0); for (int i = tl; i <= m; i++) msk[i - 1] = 0; for (int i = m + 1; i <= tr; i++) msk[i - 1] = 1; if (test_students(msk)) calc(m + 1, tr); else for (int i = m + 1; i <= tr; i++) ans.pb(0); return; } vector<bool> find_positive() { int i, j; clr(ans); int h = ceil(db(N) * P); int l, r; //cout << h << "\n"; if (h<1 || h>N) assert(false); int len = (N + h - 1) / h; for (i = 1; i <= N; i += len) { calc(i, i + len - 1); } if (i != N + 1) { i -= len; calc(i, N); } if (sz(ans) != N) assert(false); 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 8 ms | 344 KB | Output is correct |
3 | Correct | 8 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 5 ms | 344 KB | Output is correct |
8 | Runtime error | 7 ms | 440 KB | Execution killed with signal 6 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 344 KB | Output is correct (P=0.001, F=15.1, Q=17.7) -> 53.29 points |
2 | Runtime error | 1 ms | 600 KB | Execution killed with signal 6 |
3 | Halted | 0 ms | 0 KB | - |