# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1134423 | ReLice | COVID tests (CEOI24_covid) | C++20 | 0 ms | 436 KiB |
#include <bits/stdc++.h>
#define ll int
#define ld double
#define pb push_back
#define pf push_front
#define ins insert
#define fr first
#define sc second
#define endl "\n"
#define ar array
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
void start(){ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);}
ll N;
double P;
ll t;
vector<bool> ans, cur;
bool check(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';
}
void dnc(ll l, ll r){
for(ll i=l;i<=r;i++) cur[i] = 1;
bool f = check(cur);
for(ll i=l;i<=r;i++) cur[i] = 0;
if(!check(cur)) return;
if(l == r) {ans[l] = 1; return;}
ll m = (l + r) / 2;
dnc(l, m);
dnc(m + 1, r);
}
vector<bool> find_positive() {
ll i;
ll n = N;
cur.resize(n);
ans.resize(n);
dnc(0, n - 1);
return ans;
}
int main() {
start();
scanf("%d %lf %d", &N, &P, &t);
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |