#include <bits/stdc++.h>
using namespace std;
mt19937 rng;
int Ask(vector<int>& ask) {
cout << "Q ";
for (int i: ask) cout << i;
cout << endl;
char c;
cin >> c;
if (c == 'W') return -1;
if (c == 'P') return 1;
return 0;
}
void solve(int n, double p) {
vector<int> ans(n, 1);
vector<int> idx(n);
for (int i = 0; i < n; ++i) idx[i] = i;
shuffle(idx.begin(), idx.end(), rng);
vector<int> ask(n);
for (int i = 0; (1<<(i+1)) < n; ++i) {
for (int j = 0; j < n; ++j) {
ask[idx[j]] = 0;
if (j&(1<<i)) ask[idx[j]] = 1;
}
int res = Ask(ask);
if (res == -1) return;
for (int j = 0; j < n; ++j) {
if (ask[j]) ans[j] &= res;
}
for (int j = 0; j < n; ++j) ask[j] = 1-ask[j];
res = Ask(ask);
if (res == -1) return;
for (int j = 0; j < n; ++j) {
if (ask[j]) ask[j] &= res;
}
}
cout << "A ";
for (int i = 0; i < n; ++i) cout << ask[i];
cout << endl;
}
int main() {
int n, t;
double p;
rng = std::mt19937(chrono::steady_clock::now().time_since_epoch().count());
cin >> n >> p >> t;
while (t--) {
solve(n, p);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |