Submission #1044171

#TimeUsernameProblemLanguageResultExecution timeMemory
1044171Mher777COVID tests (CEOI24_covid)C++17
33.05 / 100
1856 ms596 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <iomanip> #include <array> #include <string> #include <algorithm> #include <cmath> #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 <utility> #include <random> #include <cassert> #include <fstream> using namespace std; mt19937_64 rnd(7069); typedef int itn; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef float fl; typedef long double ld; using vi = vector<int>; using vll = vector<ll>; using mii = map<int, int>; using mll = map<ll, ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ff first #define ss second #define pub push_back #define pob pop_back #define puf push_front #define pof pop_front #define mpr make_pair #define yes cout<<"Yes\n" #define no cout<<"No\n" #define all(x) (x).begin(), (x).end() #define USACO freopen("feast.in", "r", stdin); freopen("feast.out", "w", stdout); const int dx[8] = { -1, 0, 1, 0, -1, -1, 1, 1 }; const int dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 }; const int MAX = int(1e9 + 5); const ll MAXL = ll(1e18) + 5ll; const ll MOD = ll(1000000007); const ll MOD2 = ll(998244353); /// 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'; cout << "Q " << mask_str.c_str() << '\n'; fflush(stdout); char answer; cin >> 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, harc; int n; void rec(int l, int r) { int sq = sqrt(r - l + 1), cur = 0; if (P == 0.001) { sq = (r - l + 1) / 2; } for (int i = l; i <= r; ++i) { ++cur; harc[i] = true; if (cur == sq || i == r) { if (test_students(harc)) { for (int j = i - cur + 1; j <= i; ++j) harc[j] = false; if (cur == 1) ans[i] = true; else { rec(i - cur + 1, i); } } for (int j = i - cur + 1; j <= i; ++j) harc[j] = false; cur = 0; } } } vector<bool> find_positive() { n = N; ans.assign(n, false); harc.assign(n, false); rec(0, n - 1); return ans; } int main() { int T; cin >> 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'; cout << "A " << answer_str.c_str() << '\n'; fflush(stdout); char verdict; cin >> verdict; if (verdict == 'W') exit(0); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...