#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
int n, t;
string p;
bool ch(int l, int r) {
if (l > r) return false;
string s = string(n, '0');
for (int i = l - 1; i < r; i++) {
s[i] = '1';
}
cout << "Q " << s << endl;
char x;
cin >> x;
if (x == 'P') return true;
return false;
}
int main() {
cin >> n >> p >> t;
if (t == 1) {
string ans = string(n, '0');
for (int i = 1; i <= n; i++) {
cout << "Q ";
string s = string(n, '0');
s[i - 1] = '1';
cout << s << endl;
char x;
cin >> x;
if (x == 'P') ans[i - 1] = '1';
}
cout << "A " << ans << endl;
char x;
cin >> x;
return 0;
}
int block;
if (p == "0.001" || p == "0.005256") block = 1000;
if (p == "0.005256") block = 81;
if (p == "0.011546") block = 50;
if (p == "0.028545") block = 31;
if (p == "0.039856") block = 19;
if (p == "0.068648") block = 15;
if (p == "0.104571") block = 7;
if (p == "0.158765") block = 5;
if (p == "0.2") block = 3;
while (t--) {
string answ = string(n, '0');
for (int i = 1; i <= n; i += block) {
int mx_r = min(n, i + block - 1);
int last = i - 1;
while (1) {
if (!ch(last + 1, mx_r)) {
break;
}
int l = last + 1, r = mx_r - 1, ans = last;
while (l <= r) {
int mid = (l + r) / 2;
if (!ch(last + 1, mid)) {
ans = mid;
l = mid + 1;
}
else r = mid - 1;
}
answ[ans] = '1';
last = ans + 1;
}
}
cout << "A " << answ << endl;
char x;
cin >> x;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Correct |
4 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
344 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
5 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=10.7) -> 90.00 points |
2 |
Correct |
59 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=49.8) -> 90.00 points |
3 |
Correct |
121 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=94.1) -> 90.00 points |
4 |
Correct |
274 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=193.9) -> 85.70 points |
5 |
Correct |
378 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=252.3) -> 82.01 points |
6 |
Correct |
580 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=379.4) -> 78.66 points |
7 |
Correct |
707 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=504.0) -> 80.95 points |
8 |
Correct |
878 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=651.1) -> 83.71 points |
9 |
Correct |
1042 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=750.3) -> 81.57 points |