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;
const int N = 1e3 + 4;
int n;
double p;
bool students[N];
bool query(int l, int r) {
cout << "Q ";
for (int i = 1; i <= n; i++) {
if (i >= l && i <= r) cout << "1";
else cout << "0";
}
cout << "\n";
cout.flush();
char ans; cin >> ans;
return ans == 'P';
}
void test(int l, int r) {
if (query(l, r)) {
if (l == r) {
students[l] = 1;
} else {
int m = (l + r) >> 1;
test(l, m);
test(m + 1, r);
}
} else {
for (int i = l; i <= r; i++) {
students[i] = false;
}
}
}
void prepare() {
for (int i = 0; i <= n; i++) {
students[i] = false;
}
}
char solve() {
prepare();
test(1, n);
cout << "A ";
for (int i = 1; i <= n; i++) {
cout << (students[i] ? '1' : '0');
}
cout << "\n";
cout.flush();
char ans; cin >> ans;
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t; cin >> n >> p >> t;
while (t--) {
char verdict = solve();
if (verdict == 'W') {
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... |