// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
int N;
double P;
int K;
string mask;
bool qry(vi sample) {
if (sz(sample) == 0) return false;
// assert(mask.size() == (size_t)N);
for(auto& i : sample) mask[i] = '1';
cout << "Q " << mask << endl;
for(auto& i : sample) mask[i] = '0';
char answer; cin >> answer;
return answer == 'P';
}
vi get() {
vi ans;
vi X; for(int i = 0; i < N; i++) X.pb(i);
function<void(vi)> dnc = [&](vi A) {
if (sz(A) == 1) {
ans.pb(A.front());
return;
}
V<vi> S(K);
for(int i = 0; i < sz(A); i++) S[i % K].pb(A[i]);
for(int i = 0; i < K; i++) if (qry(S[i])) dnc(S[i]);
};
dnc(X);
return ans;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int T;
cin >> N >> P >> T;
K = 5;
mask = string(N, '0');
// You may perform any extra initialization here.
for (int i = 0; i < T; i++) {
vi answer = get();
// assert(answer.size() == (size_t)N);
string answer_str(N, '0');
for(auto& i : answer) answer_str[i] = '1';
cout << "A " << answer_str << endl;
char verdict; cin >> verdict;
if (verdict == 'W')
exit(0-0);
}
return 0;
}
// Breathe In, Breathe Out
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |