#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int n, t;
double p;
char ask(char *q) {
char result[2];
printf("Q %s\n", q);
fflush(stdout);
scanf("%s", result);
return result[0];
}
char a[1001] = { 0 }, q[1001] = { 0 };
int main() {
scanf("%d%lf%d", &n, &p, &t);
if (t == 1) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j)
q[j] = '0' + (j == i);
a[i] = (ask(q) == 'P') + '0';
}
printf("A %s\n", a);
return 0;
}
int x = -1;
double P_[] = { 0.001, 0.005256, 0.011546, 0.028545, 0.039856, 0.068648, 0.104571, 0.158765, 0.2 };
int X_[] = { 1000, 128, 64, 28, 16, 8, 8, 4, 4, };
for (int i = 0; i < 9; ++i)
if (P_[i] == p)
x = X_[i];
assert(x != -1);
while (t--) {
for (int i = 0; i < n; ++i)
a[i] = '0';
int at = 0;
while (at < n) {
char q[1001] = { 0 };
int lb = at - 1, ub = at + x;
if (ub > n)
ub = n;
int ub0 = ub;
int nx = ub;
for (int i = 0; i < n; ++i)
q[i] = '0';
for (int i = at; i < ub; ++i)
q[i] = '1';
if (ask(q) == 'N') {
at = ub;
} else {
while (ub - lb > 1) {
int md = lb + (ub - lb) / 2;
for (int i = 0; i < n; ++i)
q[i] = '0';
for (int i = at; i <= md; ++i)
q[i] = '1';
if (ask(q) == 'P') ub = md, nx = md + 1;
else lb = md;
}
if (ub < ub0)
a[ub] = '1';
at = nx;
}
}
printf("A %s\n", a);
fflush(stdout);
char verdict[2];
scanf("%s", verdict);
if ('W' == verdict[0])
return 0;
}
}
Compilation message
Main.c: In function 'ask':
Main.c:14:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%s", result);
| ^~~~~~~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:21:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%d%lf%d", &n, &p, &t);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:86:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
86 | scanf("%s", verdict);
| ^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
344 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
8 ms |
344 KB |
Output is correct |
12 |
Correct |
8 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
344 KB |
Output is correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
7 ms |
344 KB |
Output is correct |
16 |
Correct |
5 ms |
344 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=10.7) -> 90.00 points |
2 |
Correct |
78 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=46.6) -> 90.00 points |
3 |
Correct |
147 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=90.9) -> 90.00 points |
4 |
Correct |
347 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=190.2) -> 90.00 points |
5 |
Correct |
416 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=245.7) -> 90.00 points |
6 |
Correct |
609 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=372.7) -> 84.03 points |
7 |
Correct |
903 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=502.0) -> 82.16 points |
8 |
Correct |
1250 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=663.3) -> 78.16 points |
9 |
Correct |
1400 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=776.0) -> 72.35 points |