#include <stdio.h>
#include <string.h>
#define N 1000
int min(int a, int b) { return a < b ? a : b; }
unsigned int Z = 12345;
int rand_() {
return (Z *= 3) >> 1;
}
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);
printf("Q %s\n", cc), fflush(stdout);
scanf("%s", s);
return s[0] == 'P';
}
int main() {
int t, subtask;
scanf("%d%lf%d", &n, &p, &t), m = 1 / p / 2, subtask = t == 1 ? 1 : 2;
while (t--) {
static char cc[N + 1];
int i, l, r, lower, upper;
memset(cc, '0', n * sizeof *cc), cc[n] = 0;
if (subtask == 1) {
for (i = 0; i < n; i++)
if (query(i, i + 1))
cc[i] = '1';
} else {
l = 0;
while (l < n) {
r = min(l + m, n);
lower = l, upper = r + 1;
while (upper - lower > 1) {
i = (lower + upper) / 2;
if (query(l, i))
upper = i;
else
lower = i;
}
if (lower < r)
cc[lower] = '1', l = lower + 1;
else
l = lower;
}
}
printf("A %s\n", cc), fflush(stdout);
scanf("%*s");
}
return 0;
}
Compilation message
Main.c: In function 'query':
Main.c:21:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%s", s);
| ^~~~~~~~~~~~~~
Main.c: In function 'main':
Main.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d%lf%d", &n, &p, &t), m = 1 / p / 2, subtask = t == 1 ? 1 : 2;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:57:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
57 | scanf("%*s");
| ^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
5 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 |
5 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
4 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 |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=24.5) -> 25.79 points |
2 |
Correct |
158 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=93.5) -> 20.84 points |
3 |
Correct |
276 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=172.1) -> 21.16 points |
4 |
Correct |
527 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=343.4) -> 21.57 points |
5 |
Correct |
609 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=403.4) -> 25.34 points |
6 |
Correct |
826 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=526.9) -> 32.66 points |
7 |
Correct |
1221 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=795.7) -> 25.78 points |
8 |
Correct |
1248 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=783.9) -> 47.21 points |
9 |
Correct |
1591 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=1000.0) -> 36.45 points |