QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528753 | #9162. COVID tests | makrav# | 60.04 | 300ms | 4068kb | C++20 | 4.4kb | 2024-08-23 20:54:29 | 2024-08-23 20:54:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
mt19937 rnd(time(NULL));
double rand_d() {
return (double)(rnd() % RAND_MAX) / RAND_MAX;
}
void rsh(vector<int> &x) {
for (int i = 1; i < x.size(); i++) {
swap(x[i], x[rnd() % (i + 1)]);
}
}
vector<int> fs = {4530, 15330, 28470, 57450, 73890, 109860, 147090, 191730, 219420};
void solve(int tc) {
int n, t;
double p; cin >> n >> p >> t;
for (int _ = 0; _ < t; _++) {
vector<int> res(n);
for (int i = 0; i < n; i++) {
res[i] = rand_d() <= p;
}
auto ask = [&](string s) -> bool {
#ifdef LOCAL
int ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') ans |= res[i];
}
return ans;
#else
cout << "Q " << s << endl;
char c; cin >> c;
return (c == 'P');
#endif
};
auto check = [&](string ans) {
#ifdef LOCAL
for (int i = 0; i < n; i++) {
if (ans[i] - '0' != res[i]) return false;
}
return true;
#else
cout << "A " << ans << endl;
char c; cin >> c;
return (c == 'C');
#endif
};
string ans, req;
for (int i = 0; i < n; i++) {
ans += '0';
req += '0';
}
auto solve = [&](int l, int r, bool need_check, auto&&solve) -> bool {
if (need_check) {
for (int i = l; i < r; i++) req[i] = '1';
bool rs = ask(req);
for (int i = l; i < r; i++) req[i] = '0';
if (!rs) return false;
}
if (l + 1 == r) {
ans[l] = '1';
return true;
}
if (l + 2 == r) {
req[l] = '1';
bool rs = ask(req);
if (!rs) {
ans[l + 1] = '1';
req[l] = '0';
return true;
}
ans[l] = '1';
req[l] = '0';
req[l + 1] = '1';
if (ask(req)) ans[l + 1] = '1';
req[l + 1] = '0';
return true;
}
int m = (l + r) / 2;
bool nch = solve(l, m, true, solve);
solve(m, r, nch, solve);
return true;
};
if (p >= 0.158765) {
int K = 3;
for (int i = 0; i < n; i+=K) {
for (int j = i; j < min(n, i + K); j++) req[j] = '1';
bool answ = ask(req);
for (int j = i; j < min(n, i + K); j++) req[j] = '0';
if (answ) {
solve(i, min(n, i + K), false, solve);
}
}
assert(check(ans));
}
else if (p >= 0.1) {
int K = 4;
for (int i = 0; i < n; i+=K) {
for (int j = i; j < min(n, i + K); j++) req[j] = '1';
bool answ = ask(req);
for (int j = i; j < min(n, i + K); j++) req[j] = '0';
if (answ) {
int m = (i + min(n, i + K)) / 2;
solve(i, m, true, solve);
solve(m, min(n, i + K), true, solve);
}
}
assert(check(ans));
} else if (p == 0.001) {
solve(0, n, true, solve);
assert(check(ans));
} else {
int K = 50;
for (int i = 0; i < n; i+=K) {
for (int j = i; j < min(n, i + K); j++) req[j] = '1';
bool answ = ask(req);
for (int j = i; j < min(n, i + K); j++) req[j] = '0';
if (answ) {
solve(i, min(i + K, n), false, solve);
}
}
assert(check(ans));
}
}
}
signed main() {
int tt = 1;
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> tt;
#endif
for (int i = 0; i < tt; i++) {
solve(i);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 3816kb
input:
1000 0.789673 1 P P P N P P P P P P P P P N P P P P N P P P N 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 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 N P P P P P P N N P P P P N P P P P P P P P N P P P P P P P N P P P N 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 ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 0ms
memory: 3816kb
input:
1000 0.686378 1 P N P N P N N P N N P N P P P N N P P P P P P N P P P P P N P P P P N P N P N P P P P P N P P P N P P P P N P P P P P P P P P P P N N 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 N N P P N P N P P P N P N P P P P P P P P P N P P N P P P P P P N P N P N P N ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 0ms
memory: 3828kb
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 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 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 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 N P P P P N P P P P P P P P P P P N P P P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 6ms
memory: 3876kb
input:
1000 0.669578 1 P P P P N 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 P P P P P P P N P P P P P P N N P N P N P P P P N P P P P N P P P P N 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 N 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 P N N P P P P P P P P P P P P P P P P N P P P N P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 8ms
memory: 3892kb
input:
1000 0.907052 1 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 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 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 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 P P N P P P P P P P P N ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 7ms
memory: 3860kb
input:
1000 0.844418 1 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 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 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 P P P N P P P P P N 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 N P N P P P P N P P P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 3ms
memory: 3764kb
input:
1000 0.533576 1 P P P P P N P N P P P N N P N P N P P P P N P P N P P P N P N P P P N P N P P P N P P P P P N P P P P P P P P P N P N P P P N P P P P P P P P N P P P P P P N N P N P N P P P P P P N P N P P P P P P N P P P P P P N P P P N P P N P P N P P P N P P N P P P N P P N P P N P P N P P P P N ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 0ms
memory: 3992kb
input:
1000 0.415944 1 N N P N P N P N P N P N P N P P N P N P N N N P N N N P N P P P P P P N P P N P P N P P N P P P P N P P P P P P N N P N P N N P N P N P P P N P N P N P N N N P N P N P N P P P P P P P N P P P P N P N N P N N P N P P P P P N P P P N P P P P N P P P N P P P P P P P N P N P P P P P P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 0ms
memory: 4068kb
input:
1000 0.596017 1 P P P N P P N P P N P P P P P P N P N P N P P P P P N P N P N P N N P N N P N N P N P P P P P N P P P N P P P P N P P P N P P P P N P P N P P P P P P N P N P N N N P P P P P P N P P P P N P P N P P P P N P N P N P P N P P N P P P N P P N P P P P P P P P N P P P P N P N P P P P P P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 5ms
memory: 3820kb
input:
1000 0.157686 1 N N N P P N N P P N P P N P P N N P N P P N N N P N P P N P N P P P P N P P N P P P N N P N P P N N N N N P P N N N N N P P N P P N N P N P P P N N P P N P P P P P P N N N N N P N P N P N P P N N P P P N N P N P P N N P N P P N N N P N P N N P P N P N N P N P P N P P N N N N N P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #11:
score: 10
Accepted
time: 2ms
memory: 3880kb
input:
1000 0.380215 1 N P P N P N P N P N P N P N N P P P N N P P P P P P N P P N P P N P N P N P N N P P P P P N P N N P P N N N N N P P P P N N P P P P N P N N N P N N P N P N P N P N N P P N P N N P P P P P P P P P P N N N P N P N P N P N P N N N N N P P P N P N P N P N P P P N N P P N P N N P P N N P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 0ms
memory: 3820kb
input:
1000 0.432565 1 P P P N P N N N P P P P P P N P P N N N P P P P P P N P P P N N P P P P P P N P P N P N P P P P P P N P P N P P P P P N P N P N P P P N P N P N P P P P N P N P N P N P N P N N P N P N P N N P N N P N P N P N N P N N P P P P P P P P P N P P N N P N N P P P N N P N P P P P P N P N N P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 0ms
memory: 4064kb
input:
1000 0.509199 1 P P P P N P P N P N P P N P N N P N N P P P N P P P N P P P P P P P N P P P N P P P N 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 N P P P N P N P N P N P N P P P N N P N N P P N P N P P P P N P P P P P P P N P N N P P P N N P P P P P P P P P N P N N P P P N P P P N P N P P P P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 7ms
memory: 3856kb
input:
1000 0.381646 1 N P P N P N N P P P P N N P N P N P N N P N P N P P P N N N P N P P N P N P P N P N N N P N P N P P N P N N P P P P N P P P P N P P P P P P N P N P P P P P N P N N P N N P P P N P P P N P P N P N N P P N P P N N P P N P P P P N N P N P P P N P N P N P N P N N P P N P P N P N N P P N ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 7ms
memory: 4064kb
input:
1000 0.42815 1 P N P P P N P N P P P P P P N N P N N P N N P P P P N N P P P P P N P P P P N P P N P P N P N P P N P N P N P N P P P N P N N P P N N P P P N P P P N P P P P P N P P P P P P N P P P P P N P P P N N P P N P P N P P P P N P P P P N P N P N P N P P P P P P P P P P P N P N N P N P N P P N...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 4ms
memory: 3888kb
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 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #17:
score: 10
Accepted
time: 1ms
memory: 4068kb
input:
1000 0 1 N N N N N N N N N N N N N N N N N N N N C
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Subtask #2:
score: 50.04
Acceptable Answer
Test #18:
score: 90
Accepted
time: 0ms
memory: 3816kb
input:
1000 0.001 300 N C P N P N N P P P N N P N N N N N C P N N P N P N P N P N N N P N N P N N N P P P N N P N P N N N N C N C N C P P N P N P N N N P P N N N N N C P N N P P P N N N N N N N N C N C N C P P N P P P P N P N N N N N N N N C N C P N N P N P N P P N N N N N P P P N N P P P N N N N N C P N P...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
points 1.0 1.0 Output is correct (P=0.001, F=15.1, Q=13.8) -> 90.00 points
Test #19:
score: 50.04
Acceptable Answer
time: 31ms
memory: 4024kb
input:
1000 0.005256 300 N P N N N P P N N P P P P N P N N N N N N N N N P N N N P P N N N N N N N N P N P N P P N N N N N N P P P N P P N N N N C N N N N N N N N N N N N P P P P N N N N N N N N N N P P P P N N P N N N N P P P N P N N N N N N C N N N N N N N N N N N N N N N N N N P P N N P N N N N N C N N ...
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.5560 0.556 Output is correct (P=0.005256, F=51.1, Q=61.3) -> 50.04 points
Test #20:
score: 56.75
Acceptable Answer
time: 46ms
memory: 3824kb
input:
1000 0.011546 300 P P N P N N P N N P P P P P N N N N N N N P N N P P N N N N N P P P P N P P N P P N P N N N P P N N N P N P N P P N N N N N N N N N N N P P P N N P N N N P P P P N P N N N N P N N P P P N N N P P N N P P N N N C N P N N N N P N N N N N N N P P P N N N P N N N N N N N N N N N P P P ...
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.63055555560 0.6305555556 Output is correct (P=0.011546, F=94.9, Q=108.8) -> 56.75 points
Test #21:
score: 53.81
Acceptable Answer
time: 119ms
memory: 3768kb
input:
1000 0.028545 300 P P P P P P N N N N N P N P P N N P N N N P N P N N N P N P P P N N N N N P P P N N N P N P P P N N N N P N P N P N N N P N P N N N N N P P P N P N P N N P N N P N N P P N N N P N N P P P N P N P P N P P N P N P P N N N N P P N P N N P N N N P N P N N P N N P N P P N N N N P N P P ...
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.59788888890 0.5978888889 Output is correct (P=0.028545, F=191.5, Q=223.7) -> 53.81 points
Test #22:
score: 52.49
Acceptable Answer
time: 130ms
memory: 3860kb
input:
1000 0.039856 300 P P P N N P N N P P P N N P N P P N N N N N N P P P N P N P N N N P P N P N N P N P N P P N N P N P N N P N P P P N P P N P N P N N N P P P P P P N N N P P N N P N N P P N P N N N N P P P P P P N N N P N N N P N N N P N P N N N N N P P N P P N N N N P N N N N P N P P N N N N N N P ...
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.58322222220 0.5832222222 Output is correct (P=0.039856, F=246.3, Q=290.3) -> 52.49 points
Test #23:
score: 50.75
Acceptable Answer
time: 183ms
memory: 3988kb
input:
1000 0.068648 300 P P N P P N N N P P P N P P N P P N P P N N N P P P P P N P N N P N P N N P P P P P N N N N N P P P P P N N P N P N P N P P N N P P N N P N P N N P N P N N P N N N P P P N N N N P N P N N P P P P N P P N N N N N P P P N P P N N P N P P N N P N N P N N N P P P P N N P N N N P P N N ...
output:
Q 1111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.56388888890 0.5638888889 Output is correct (P=0.068648, F=366.2, Q=437.0) -> 50.75 points
Test #24:
score: 51.75
Acceptable Answer
time: 208ms
memory: 3892kb
input:
1000 0.104571 300 N N N N N P P N N N N P N P P N P P P P N N N N N P N P P N P P N N P N P N P N P P N N P P N N P P P P N N P P P N P P N N N N N N N N N P P P N N N N N P P P N N N N N P P N N N N N N N N P N P P N P P P N N P P P N P N P N P N N N P N P P N N N P P N N N N N P N P P N P P N P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.5750 0.575 Output is correct (P=0.104571, F=490.3, Q=580.9) -> 51.75 points
Test #25:
score: 75.93
Acceptable Answer
time: 300ms
memory: 3816kb
input:
1000 0.158765 300 N N N N N P N P N N P N P N N N P N N P P N N N N N N N N N N N N P P P N N N N N N P N N N N N N P N P N N N N N P N N N N P N P N N N N P P N N N N N P P N P P N P N N N N P P N N N N N N N N P N P P P P N N N P N P N N N N N N N N P N P N N N P N N P N N P P P N N P P N N P N P ...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.84366666670 0.8436666667 Output is correct (P=0.158765, F=639.1, Q=668.7) -> 75.93 points
Test #26:
score: 81.57
Acceptable Answer
time: 281ms
memory: 3824kb
input:
1000 0.2 300 N P N P N N P P P N N N N N N P N N P N P P N P N P N P P N P P P N N P P P N N P P P P N N P N P N P N P N N N N N P N P P P P N N P P N N P P N P N P N P N N N N N N P N P N P P P P N P N P N N P N N P P P N P N N N P N N P N P N P P N N N N P N N P P P P N P N P N N N P P N N N P N N...
output:
Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 0.90633333330 0.9063333333 Output is correct (P=0.2, F=731.4, Q=750.3) -> 81.57 points