QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#544129 | #9162. COVID tests | 251Sec | 22.95 | 1473ms | 15884kb | C++14 | 1.3kb | 2024-09-02 10:01:26 | 2024-09-02 10:01:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int N, T;
double P, p[1005];
double f[1005][1005];
int g[1005][1005];
bool Query(int l, int r) {
printf("Q ");
for (auto i = 0; i < N; i++) putchar('0' ^ (i >= l && i <= r));
putchar('\n');
fflush(stdout);
char c; scanf(" %c", &c);
return (c == 'P');
}
void Solve() {
int i = 0, j = -1;
vector<bool> ans(N);
while (i < N) {
if (j != i) {
int k = g[N - i][j - i + 1]; bool x = Query(i, i + k - 1);
if (x) j = i + k - 1;
else i += k, j = i - 1;
}
else if (j == i) ans[j] = 1, i++;
}
printf("A ");
for (int i = 0; i < N; i++) putchar('0' ^ ans[i]);
putchar('\n');
fflush(stdout);
scanf(" %*c");
}
int main() {
scanf("%d%lf%d", &N, &P, &T);
p[0] = 1;
for (int i = 1; i <= N; i++) p[i] = p[i - 1] * (1 - P);
for (int i = 1; i <= N; i++) {
f[i][1] = f[i - 1][0];
for (int j = 2; j <= i; j++) {
f[i][j] = 1e18;
for (int k = 1; k <= j; k++) {
double t = (1 - p[k]) / (1 - p[j]), w = t * f[i][k] + (1 - t) * f[i - k][j - k] + 1;
if (w < f[i][j]) f[i][j] = w, g[i][j] = k;
}
}
f[i][0] = 1e18;
for (int k = 1; k <= i; k++) {
double w = p[k] * f[i - k][0] + (1 - p[k]) * f[i][k] + 1;
if (w < f[i][0]) f[i][0] = w, g[i][0] = k;
}
}
while (T--) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 266ms
memory: 15872kb
input:
1000 0.789673 1 P N P P P P P P N P P N P N P P P P P N P P P P P P N P P P P P P P P P P P P P P P P P P N N N P P P P N P P P P N N P P P N P P P P N P P P P P N N P N P P P P P N P P P P P P P P P P P P P P P P P P N N P N P P P P P P P P N P N P P P N N P P P P P P P P P P P P P P P P P P P P N ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 260ms
memory: 15444kb
input:
1000 0.686378 1 N P N N N P N N P N P P N N P P P P N P P P N P P P N N P N P P P N N N P N P P P N P P P P P P N N P P P N P P P P P P P P P P P P P P P P P P N N P P N N N P P N P N P P P P P N P N N P P P N P N N P N P P P P N P N P P P P N P P N P P P N P N P P N P N N P P N P N P P N N P N N P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 262ms
memory: 15244kb
input:
1000 0.873862 1 P P P P P P P P P P P P P P P P P P P P N P P P P P P P P P P P P P P P N P P P P P P P P P N P P P P P P P P P P P P P N P P P P P P P P P N P P P N P P N P P P P P P N P P P P P N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P N P P P P P N P P N P P P P P P P P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 266ms
memory: 15060kb
input:
1000 0.669578 1 P P N P P P P P N P N P P P N P P P P P P P N P P P P N N P N P N P P N P P N P P N P N P P P P P P P P P P P P P N N P P N P P N N P P N N P N P N P N P P N N P P P P P P P P P P N P P N P P N P P P P P P N P P P P N N N P N P P N P P N N P P N P P P N P P N P P P P P N P P N P P P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 258ms
memory: 15884kb
input:
1000 0.907052 1 P P P P P P P N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P N P P P P N P P P P P P P P P P P P N P P P P P P P P P P P P P P P P P P P P P P N P P P P P N P P P P P P P P P N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P N P P P N P P P P N N P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 251ms
memory: 15220kb
input:
1000 0.844418 1 P P P P P P P P P P P P N P P P P P P N P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P N P P P P P N P P P N P P P P P N P P P P P P N P P P N P N P P N P P P N P P N P P P N N N P P P P N N P N N P P P P P P P N P N P P P P N P P P P P P P P P P P P P P P P P P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 260ms
memory: 15456kb
input:
1000 0.533576 1 P P P N N N N P P N N P N P N P P N P N N P N P N P P N P N P N P P P P N N N P P P P P N N P P N P P P P P N P P P P N N N N N P N P P P N P N P P P N P P P P N P N P P N N P N N P N P P N N P N P P N N P N N P N N P P N N N N P N P N N P N N P P N P P P P P N N N P P N P N P N P P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 260ms
memory: 15376kb
input:
1000 0.415944 1 N N N N N N N P N N P N N P N P N N N P N N N N N N N N N P N N N N P P P P N P N N P N N P N N P P N P P P N N P N P N N N N N P N P N P N P N N N P N N N N P N N P P P P P N N N P P N N N P N N P N P P P N P P N P P P N P N P P P P P N N N P P P P P P P P N N N P P N N N N N N P P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 268ms
memory: 15884kb
input:
1000 0.596017 1 P N P P N N P N N P P P N P N N P P P N P N P N N N P N N P N N P N P P P N P P N P P P N P N P P P N P N N P P P N P N N N P N N N P P P N P P P N N P N N P P N N P N P N N P N N P N P P N N P P P P N P P P N N P P P P P P N P P P N P P N P P P P P P P P N P P P P N N P P P N P N P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 260ms
memory: 15420kb
input:
1000 0.157686 1 N N N P P N P P P P N P P N P P P P P P P N P P P N P P P N N P N P P N P P P P N P P N P P P P P P P N P P P P P N P P P N P P N P P P N N N N P N P P P N N N P N P P N P P P P P P N P N P P N P P P P P P N N P P N P P P P P P P P P P P P N N N N P N P P P P N P P P N P P N P P P N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 260ms
memory: 15260kb
input:
1000 0.380215 1 N P N P P N P N P P N P P N P N P P P P P N P P N P N P P P P P P P N P P P P N P N P P N P N P P N P N P P P P P P P P N N P N P P P P N N N N N N N P P P P N N P P P P N P N P P N N P N P P P N P P N P P N N P P N N P P P P P P P P P P P P P P N N N N N P P N P P N P N P P N N N N ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 270ms
memory: 15220kb
input:
1000 0.432565 1 P N P N N P N N N P P P N P P N N N N N N N N N P P P N P P N N P P P P N P P N N N N P P P P N P N N P P P N N N N P N P N P N P N P P N N P N N P N N N P N P N N N P N N P N P N N N P N N P P P P P P N P N N N N N N N P P N P N N N N P P P N P N N P P P N P P P P P P N P N P P N P ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 253ms
memory: 15524kb
input:
1000 0.509199 1 P P N P N N N P P N N N N N P N N P P N P P N P P P P P N N P N P P N P P P P P P P P P P N P P P N N P N P P N P N P N N P N P N P N N N N N P P N N N P P P N N P P P P N N N N P P N P N N N P P P P P N N N P P N P P N P N P P P N N P P N N N N N N P P P N N P P N N N N N N P P N N ...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 259ms
memory: 14920kb
input:
1000 0.381646 1 N P N P P N N P P P P P P N N P N P P N P N P P P N P P P N P P P N P P N N N P N P P P P N N P P P P N N P N P P N N P P P N P P N N P P P P P P P N P P P P P N P P P P P P P N P P P N P P P P P P N N P N P P N P P P P P N P P P P P N P P P P N N P P P P N P P N N P N P P N P P P P ...
output:
Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 252ms
memory: 15196kb
input:
1000 0.42815 1 N P P N P N P P P N N P N N P N N P P P N N N N P P P N N N P P N P N N P N N N P P N N N N P N N P P N P N N N N P N N N N N P N P P N P P P P N N N P P P N P P P N P P N P N N N P N N P N N P P N P P N N P N N P P P P P P P N N N P N P N P N N N N N N N P N N N P N P P P P N N N P N...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 250ms
memory: 15160kb
input:
1000 1 1 P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P...
output:
Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 254ms
memory: 15684kb
input:
1000 0 1 N C
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 12.95
Acceptable Answer
Test #18:
score: 16.76
Acceptable Answer
time: 311ms
memory: 15232kb
input:
1000 0.001 300 N N C N P P N P P N P P P P P N P P P P P P N P P P P P P P P P N C N P N P P N P P P N P P P P N P P P P P P P P P P N P P P P P N P P P P P P P N P P P P P P P P P P P N P P P N P P P P N P P P P P P N P P P P P P P N C N N C N N C P N P P P N P P P P P N P P P P P P P P N P P P P P...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
points 0.18622222220 0.1862222222 Output is correct (P=0.001, F=15.1, Q=31.6) -> 16.76 points
Test #19:
score: 12.95
Acceptable Answer
time: 436ms
memory: 15480kb
input:
1000 0.005256 300 P N P P P N P P P P N P P P P P N P P P P P P P N P P P P P P P P P P P P N P P P P P P P N P P P P P P P P N N P N P P P P N P P P P P N P P P P P P P N P P P P P P P P N N P N P P P P P N P P P P P P N P P P P P P P N P N P P N P P P N P P P P P P N C N N N N P N P P P N P P P P ...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.14388888890 0.1438888889 Output is correct (P=0.005256, F=51.1, Q=127.1) -> 12.95 points
Test #20:
score: 15.24
Acceptable Answer
time: 598ms
memory: 15308kb
input:
1000 0.011546 300 P P N P P P N P P P P P P P P P N P P P N P P P P P P N N N P N P P P N P P P P P N P P P P P P N P P P P N P P P P P N P P P P P P P P P P P N P P P P P P P P P P P N P P P P P P P P N P P N P P P P N P P P P P N P P P P P P P P P N P P P P N P P P P P N P P P P P P N N N N N N N ...
output:
Q 1111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.16933333330 0.1693333333 Output is correct (P=0.011546, F=94.9, Q=211.3) -> 15.24 points
Test #21:
score: 17.84
Acceptable Answer
time: 757ms
memory: 14912kb
input:
1000 0.028545 300 P P P P P N N N P P N P P P N P P P P P N N P P N P P P N P P P P N P P P P P P P P N P P P P N P P P P P N N P N P N P P N P P P N P P P P P P P P N P P P P N P P P P P N P P P P N P P P P P N N N P N P N P P N P P P N P P P P N P P P P P P N P N P P N P P P P P P N P P N P P P N ...
output:
Q 1111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.19822222220 0.1982222222 Output is correct (P=0.028545, F=191.5, Q=385.1) -> 17.84 points
Test #22:
score: 17.78
Acceptable Answer
time: 942ms
memory: 14900kb
input:
1000 0.039856 300 P N P P P P N P P P P P N P P P N P P P P P P P P N P P P P N P P P P P N N N N N N N P P N P P P P P N P N P P P P P P P P P N P P P P P P P N P P P P N P P P P P P P N P P P N P P P P P P P N P P P N P P P P N P P P P P P P P N P P P P N P P P P P N N P P N P P P P N P P P P P P ...
output:
Q 1111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.19755555560 0.1975555556 Output is correct (P=0.039856, F=246.3, Q=496.4) -> 17.78 points
Test #23:
score: 22.08
Acceptable Answer
time: 1116ms
memory: 15188kb
input:
1000 0.068648 300 N P N P P P P P P N P P P N P P P P P P N P P P N P P P P P P P P N P P P N P P P P P P P P P P P N P P P P P N P N P P P P P N P P P P N N P P N P P P P P N P N P P P P P N P N P P P P N N P N P P P N P P P P N N P P P N P P P P N N N N N N P N P N P P P N P P P P P N P N P P P P ...
output:
Q 1111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.24533333330 0.2453333333 Output is correct (P=0.068648, F=366.2, Q=647.9) -> 22.08 points
Test #24:
score: 28.52
Acceptable Answer
time: 1106ms
memory: 15192kb
input:
1000 0.104571 300 N N N P N P P N P P P N N P P P P P N P P P P P P N N N P N P P P P N P P P P N P N P P N P P P P N P P P N P P P P N P P P P P P N P P P P P N P P P N N N N N P N P P N P P P N N P N P P N P P P N N P N P N P P P N N N N P N P N P P P P P N P P P P N P P N P P P P N P P P P N P P ...
output:
Q 1111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.31688888890 0.3168888889 Output is correct (P=0.104571, F=490.3, Q=754.5) -> 28.52 points
Test #25:
score: 28.83
Acceptable Answer
time: 1473ms
memory: 14936kb
input:
1000 0.158765 300 N N N N P P P N P P N P P P N N P P N P P P P P P N N N N N N N N P N P P N P P P P P N P P P N N N N P P N P P P N N N P P N P P P N N N P N P P N P P P N P N P P N P P P N N P N P P P N N N P N P P P P N P P P N P P P N P N P P P N N N N N N P P P P P P P P P N N P P N P P P N N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.32033333330 0.3203333333 Output is correct (P=0.158765, F=639.1, Q=978.1) -> 28.83 points
Test #26:
score: 40.94
Acceptable Answer
time: 1366ms
memory: 15632kb
input:
1000 0.2 300 N P N P P N P N P P P N P P N N N N N P N P N P P P N P P P P N P N P P P N P P P N P N P P P N P P N P P P N P P N P P P P N P N P N P P P N P N P P N N N N P N P N P P P P P P N P N P N P P N P N P N P P N P P N P P N N N N P N P P P N P P P P P N P N P P N N P P P P P N P P P N P N P...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.45488888890 0.4548888889 Output is correct (P=0.2, F=731.4, Q=950.5) -> 40.94 points