QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528734 | #9162. COVID tests | makrav# | 0 | 13ms | 4080kb | C++20 | 4.7kb | 2024-08-23 20:44:22 | 2024-08-23 20:44:22 |
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.2) {
int K = 2;
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) {
for (int j = i; j < min(n,i+K); j++) {
req[j] = '1';
if (ask(req)) {
ans[j] = '1';
req[j] = '0';
continue;
}
else {
if (j < min(n, i + K) - 1) {
ans[j + 1] = '1';
req[j] = '0';
}
break;
}
}
}
}
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 {
int K = 100;
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);
}
}
}
}
}
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;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 8ms
memory: 3872kb
input:
1000 0.789673 1 P P P N P P P P P P P P P P P P N P P N 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 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 P P P P P P P N P P P P 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 N P N P P N P P P P P P P P N P P P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #2:
score: 10
Accepted
time: 6ms
memory: 3928kb
input:
1000 0.686378 1 P P N N P P N N P P P N P P P P N P P P P P P P P N P P P P P N P P P P N P P P N P P P P P P N N P P P N 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 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 N P P P N P P N P P P P P P P P P P N P P N P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #3:
score: 10
Accepted
time: 4ms
memory: 4020kb
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 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 P P N 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 P P P P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #4:
score: 10
Accepted
time: 5ms
memory: 3848kb
input:
1000 0.669578 1 P P P P P N P P P P P P P P P N P N 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 N P P N P N P P N P P N P P P P P N P P P N 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 N P N P P P N P P P P N P P P P N P P N P P P N P 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 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #5:
score: 10
Accepted
time: 0ms
memory: 3840kb
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 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 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 N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #6:
score: 10
Accepted
time: 13ms
memory: 3788kb
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 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 P P P P P 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 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 P N P P P P P P N P P N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #7:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
1000 0.533576 1 P P P P P P N P N P N P P P N P N P P N P N P P P N P P N P 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 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 N N P P P N P P P P P P N P P N P P P P P P N P P P P P P P P P N P N P P P N P N P N P P N P P P P N P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #8:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
1000 0.415944 1 N P N P N P N P P N P P N P N P N P N N N P P N N P N P P P P P P P P N P N P P N P P N N P P P P P N P P P P N P P P N P P N N P P P N P P N P P P N P P N P N P P N P N P N P N P P P P P P P P P N P N P P P P N P N P N P P N P P P P P P N P P P P P N P P P P P N P P N P P P P P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #9:
score: 10
Accepted
time: 4ms
memory: 3840kb
input:
1000 0.596017 1 P P P N P P P P N P P N P P N P P P P P N N P P P P P P N P P P N P P N P N P P N P P N N P P P N P P P P P P N P P P P P N P P P P P N P N P P P P P N P N P P P P P P N P P N P N P P N P N P P P P P P N P P P P P P N P N P N P P P P N P P N P P P N P N P N P P N P P P P N P P P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #10:
score: 10
Accepted
time: 6ms
memory: 3848kb
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: 0ms
memory: 4076kb
input:
1000 0.380215 1 P N P N P N P N P N P P N P N P P P P P N N P P N P P P P P N P P N P N P P N P N P P N P N P P P P P P P N P N P N P P P N N N N P N P N P P P N N P P N P P N P N P P N N P P P N P P N P P N N P N P P N P N P N P P P P P P P P P P P N N N P P P N P N P N P N N N P P N P N P P N N P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #12:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
1000 0.432565 1 P P P N P P N P P N N P P N P P P P P N P P N N N P P P P P P N P P P P N P P P P P P P P P N P P N P N P N P P P P P P N P P P N P N P P P P N P N P P N P P P N P P N P P P N P P P P N P P N P P N N P P N P N P N P N P N P P N P P P N N P P P N P N P P P P P P P P P P N P P N N P N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #13:
score: 10
Accepted
time: 0ms
memory: 3844kb
input:
1000 0.509199 1 P P P P P N P N P N P P P N N P N P P N P P N P P N P P P P P N P P P P P P P P N 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 N P P P P P P N P N P P N P P N P P P N P P N P P N P N P P N N P N P N P P P N N P P P P P P N P P N P P P P P P N N P P N P P N P P P N N P P P P P ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #14:
score: 10
Accepted
time: 6ms
memory: 4044kb
input:
1000 0.381646 1 P N P N N P P P P P P N N P P P N N P P P N P P N P P P N P P N N P N P P P N P P P P N P N P N N P P P N P P N P N P N P P P P P N P P P N P P P P P P N P P N P P P P P P N N P P P N P N P P P N P P P P P N P P N P N P N P P P N P N N P P N N P P P P N P N P N P P P N P P N P P N N ...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #15:
score: 10
Accepted
time: 3ms
memory: 4080kb
input:
1000 0.42815 1 P P N P P N P P P N P P P P P P N P N P N P P N P P N P P P N P P P P P P N P N P P P P P N N P P P N N P P P P N P N P P N P P N P P N P P P N N P P N N P N P N P P N P P N P P P P P P P P N P N P P P P P N P P P P P N P P P N P P N P N P P N P P N N P P P P P N P P P N P N P N P P P...
output:
Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #16:
score: 10
Accepted
time: 6ms
memory: 4008kb
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 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
points 1.0 1.0 translate:success
Test #17:
score: 0
Wrong Answer
time: 1ms
memory: 3836kb
input:
1000 0 1 N N N N N N N N N N
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer d of file - token expected
Subtask #2:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 6ms
memory: 3840kb
input:
1000 0.001 300 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N...
output:
Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer d of file - token expected