QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528654 | #9162. COVID tests | makrav# | 0 | 3191ms | 4000kb | C++20 | 3.2kb | 2024-08-23 18:59:31 | 2024-08-23 18:59:31 |
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;
int qtot = 0;
int sm =0;
for (int i = 0; i < t; i++) {
for (int j = 0; j < n; j++) sm += (rand_d() <= p);
}
int exp = (sm + n - 1) / n + 5;
for (int lol = 0; lol < t; lol++) {
vector<int> res(n);
for (int i = 0; i < n; i++) {
res[i] = rand_d() <= p;
}
auto ask = [&](string s) -> bool {
qtot++;
#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
};
vector<int> poss(n);
iota(all(poss), 0);
while (sz(poss) > 2 * exp) {
double newp = (double) exp / (double) sz(poss);
int siz = (sz(poss) - exp + 1) / 2;
if (siz > sz(poss) - exp) siz = sz(poss) - exp;
while (true) {
rsh(poss);
string S;
for (int j = 0; j < n; j++) S += '0';
for (int i = 0; i < siz; i++) S[poss[i]] = '1';
if (!ask(S)) {
reverse(all(poss));
for (int j = 0; j < siz; j++) poss.pop_back();
break;
}
}
}
string answ;
for (int i = 0; i < n; i++) answ += '0';
for (int j = 0; j < sz(poss); j++) {
string S;
for (int i = 0; i < n; i++) S += '0';
S[poss[j]] = '1';
if (ask(S)) answ[poss[j]] = '1';
}
if (!check(answ)) return;
}
//cout << qtot << '\n';
#ifdef LOCAL
double pts = 0;
if (qtot <= fs[tc]) {
pts = 90;
} else if (qtot <= 10 * fs[tc]) {
pts = (double)fs[tc] / (double)(fs[tc] + 4 * (qtot - fs[tc]));
}
cout << "gained " << pts << '\n';
#endif
}
signed main() {
int tt = 1;
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> tt;
#else
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#endif
for (int i = 0; i < tt; i++) {
solve(i);
}
return 0;
}
详细
Subtask #1:
score: 0
Interactor Memory Limit Exceeded
Test #1:
score: 0
Interactor Memory Limit Exceeded
input:
1000 0.789673 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 ...
output:
Q 1101100111110010010010111000100101101110100011100100110011001000011111101001000000000010001011101000101101111010100000111111111011110100101011100010010011010111001110001000110011000001100111110100101000101110101010110111011110100000100111000101011011111000000000111010101011011001000101101001001001...
result:
Subtask #2:
score: 0
Wrong Answer
Test #18:
score: 21.14
Acceptable Answer
time: 38ms
memory: 3832kb
input:
1000 0.001 300 N N N N N N N N N N N N N N N N N C P N P N P N P N N N N P N N N N N N N N P N C P N 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 N P P P P N P P P P P P P P P N N P P P P N N N N N P P N N P C N N N N N N N N N N N N N N N N N C N N N N N N N N N N N N N N N N N C N N N P...
output:
Q 0101011010000100000111111101000001101010010101001111000101011111101011011111110100010001011010010101111000100101001111001011010101001110011100100001110000011011010011010000011011000011000101011001000010000001111000010010101111000011001111111110010111101101101000111110111001000001101011101101100111...
result:
points 0.23488888890 0.2348888889 Output is correct (P=0.001, F=15.1, Q=27.4) -> 21.14 points
Test #19:
score: 0
Wrong Answer
time: 3191ms
memory: 4000kb
input:
1000 0.005256 300 P P P P P P P P P P P P P P P P 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 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 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 P N P P P P P N N N P P ...
output:
Q 0101011010000100000111111101000001101010010101001111000101011111101011011111110100010001011010010101111000100101001111001011010101001110011100100001110000011011010011010000011011000011000101011001000010000001111000010010101111000011001111111110010111101101101000111110111001000001101011101101100111...
result:
points 0.0 0.0 translate:wrong