QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528666 | #9162. COVID tests | makrav# | 0 | 68ms | 3764kb | C++20 | 3.5kb | 2024-08-23 19:15:34 | 2024-08-23 19:15:35 |
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;
}
int curtot = 0;
auto ask = [&](string s) -> bool {
qtot++;
curtot++;
#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) > exp) {
double newp = (double) exp / (double) sz(poss);
int siz = 1;
double P=1-newp;
while(siz<=sz(poss)-exp&&P>=0.05){
siz++;
P*=(1-newp);
}
//cout<<siz<<' ';
int ci = 0;
while (true) {
ci++;
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;
}
}
//cout<<ci<<'\n';
}
//cout<<curtot<<' '<<sz(poss)<<'\n';
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';
}
assert(check(answ));
}
#ifdef LOCAL
double pts = 0;
if (qtot <= fs[tc]) {
pts = 90;
} else if (qtot <= 10 * fs[tc]) {
pts = 90 * (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 Judgement Failed
Test #1:
score: 0
Interactor Judgement Failed
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 0001101011110011011001101000100110011111001011111001110000100000110100111011110000000000001110010011000101101001101101010111110110010111001111000011010100110110000110100101001000000001010001111100110001010011111010101111100111001100010111010111110001000110000111110011111010010010110101111010000011...
result:
Subtask #2:
score: 0
Interactor Memory Limit Exceeded
Test #18:
score: 21.67
Acceptable Answer
time: 68ms
memory: 3764kb
input:
1000 0.001 300 N N N N N N N N N N N N N N C N P N N P N P N N N N N N N N N P C P P P P P P P P P P N P P P P P P P N 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 P P P P P P P P N P P N N P N C 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 C P P N P P P P N N P N N P P P N P N P...
output:
Q 0010110110001010111101001111110010100001110100001010101110011111000011000100001100110111110010001110001101100000010011110100011100100101101100111111001101110011010101100001110001100101110110101010011011110111000001001001000000101111110010010101001011000001000111000011010110000001101010000001011100...
result:
points 0.24077777780 0.2407777778 Output is correct (P=0.001, F=15.1, Q=27.0) -> 21.67 points
Test #19:
score: 21.67
Acceptable Answer
time: 68ms
memory: 3764kb
input:
1000 0.005256 300 P P P P P P P P P N P P P P P P 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 N 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 N P P P P N P P P P P N P P P P P P N P P P P P P P N N P N P P P P C P N P P P P P N P P P P P N P P N P P N ...
output:
Q 1100000001011000011100011011110001101000111011110010010101000111001010000000000000100100111011000110101000010110010011011110100100001100111001100100100000000111100010010110101100000100111110000010000101111100101010111000000010010011001100101001110011111101000110100100000101011000000011100011000101...
result:
points 0.24077777780 0.2407777778 Output is correct (P=0.001, F=15.1, Q=27.0) -> 21.67 points
Test #20:
score: 0
Interactor Memory Limit Exceeded
input:
1000 0.011546 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 P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P 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 1011111110011000000011101100000000000000111101011000101000100000010001001011001011011001111000000110001010000001000010110000111101000110110000110100101100000000111001000110100000011010000100100110000011110100100110000000100101001110000101110000001010010100001010010111011100011010001000001000011010...