#include <stdio.h>
#include <string.h>
#define N 1000
int min(int a, int b) { return a < b ? a : b; }
int n, m; double p;
int query(int l, int r) {
static char cc[N + 1], s[2];
memset(cc, '0', n * sizeof *cc), memset(cc + l, '1', (r - l) * sizeof *cc), cc[n] = 0;
printf("Q %s\n", cc), fflush(stdout);
scanf("%s", s);
return s[0] == 'P';
}
char cc[N + 1]; int b;
int solve(int l, int r, int has) {
int m;
if (!has && !query(l, r)) {
memset(cc + l, '0', (r - l) * sizeof *cc);
return 0;
}
if (r - l > 1) {
m = (l + r) / 2;
solve(m, r, !solve(l, m, 0));
}
return 1;
}
int main() {
int t;
scanf("%d%lf%d", &n, &p, &t), m = 1 / p;
while (t--) {
int l;
memset(cc, '1', n * sizeof *cc), cc[n] = 0;
for (l = 0; l < n; l += m)
solve(l, min(l + m, n), 0);
printf("A %s\n", cc), fflush(stdout);
scanf("%*s");
}
return 0;
}
Compilation message
Main.c: In function 'query':
Main.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%s", s);
| ^~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:38:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | scanf("%d%lf%d", &n, &p, &t), m = 1 / p;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:46:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%*s");
| ^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
6 ms |
596 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
4 ms |
344 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
4 ms |
344 KB |
Output is correct |
16 |
Correct |
5 ms |
344 KB |
Output is correct |
17 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=13.8) -> 90.00 points |
2 |
Correct |
87 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=57.7) -> 59.34 points |
3 |
Correct |
170 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=108.9) -> 56.60 points |
4 |
Correct |
323 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=219.5) -> 56.79 points |
5 |
Correct |
422 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=280.1) -> 58.10 points |
6 |
Correct |
631 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=407.9) -> 61.83 points |
7 |
Correct |
847 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=530.3) -> 67.86 points |
8 |
Correct |
1039 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=675.9) -> 73.15 points |
9 |
Correct |
1223 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=770.0) -> 74.31 points |