This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
double power(double base, int pow) {
return pow == 0 ? 1 : power(base, pow - 1) * base;
}
void subtask_1(int n, int k) {
string covid(n, '0');
for (int i = 0; i < k; i++) {
cout << "Q " << string(i, '0') << '1' << string(n-i-1, '0') << endl;
cin >> covid[i];
covid[i] = covid[i] == 'P' ? '1' : '0';
}
cout << "A " << covid << "\n";
}
void interact(int n, double p) {
// probability of k people being all negative : (1 - p) ^ k
// find the largest k such that (1 - p)^k is large enough
const double threshold = 0.80;
for (int k = n; k >= 0; k--) {
if (power(1 - p, k) >= threshold) {
return subtask_1(n, n-k);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,t; double p; cin >> n >> p >> t;
while (t--) {
interact(n, p);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |