# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1204297 | NK_ | COVID tests (CEOI24_covid) | C++20 | 0 ms | 0 KiB |
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
V<double> QRY = {0.001, 0.005256, 0.011546, 0.028545, 0.039856, 0.068648, 0.104571, 0.158765, 0.2};
int N;
double P;
int Q = 0;
string mask, res;
bool qry(vi sample) {
if (sz(sample) == 0) return false;
// assert(mask.size() == (size_t)N);
for(auto& i : sample) mask[i] = '1';
Q++; char answer = 'N';
for(int i = 0; i < N; i++) if (mask[i] == '1' && res[i] == '1') answer = 'P';
// cout << "Q " << mask << endl;
for(auto& i : sample) mask[i] = '0';
// cin >> answer;
return answer == 'P';
}
// vi K = {2, 2, 3, 3, 4, 4, 4, 4, 4, 4};
const double eps = 1e-1;
vi get() {
vi ans;
function<void(vi, int)> dnc = [&](vi A, int d) {
if (sz(A) == 0) return;
if (sz(A) == 1) {
ans.pb(A.front());
return;
}
int M = sz(A) / 2;
vi L, R;
for(int i = 0; i < sz(A); i++) {
if (i < M) L.pb(A[i]);
else R.pb(A[i]);
}
if (!qry(L)) dnc(R, d);
else {
dnc(L, d);
if (qry(R)) dnc(R, d);
}
};
double neg = 1;
vi X; for(int i = 0; i < N; i++) {
neg *= (1 - P); X.pb(i);
if (neg < eps) {
if (qry(X)) dnc(X, 0);
X = {}; neg = 1.0;
}
}
if (qry(X)) dnc(X, 0);
return ans;
}
mt19937 rng(1009);
const int MOD = 1e4 + 7;
int randv() { return (rng() % MOD) * (rng() % MOD); }
int randint(int r) {
return randv() % r;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
N = 1000; int T = 1000;
const int INF = 1e6;
int OP = 4;
int BND = QRY[OP] * INF;
P = QRY[OP];
mask = string(N, '0');
int SUM = 0;
for (int i = 0; i < T; i++) {
res = string(N, '0');
for(int i = 0; i < N; i++) if (randint(INF) <= BND) res[i] = '1';
Q = 0;
vi answer = get();
SUM += Q;
cout << Q << endl;
// assert(answer.size() == (size_t)N);
string answer_str(N, '0');
for(auto& i : answer) answer_str[i] = '1';
// cout << "A " << answer_str << endl;
char verdict = (answer_str == res ? 'C' : 'W');
// cin >> verdict;
if (verdict == 'W') {
cout << "WA" << endl;
exit(0-0);
}
}
cout << "AVG: " << double(SUM) / T << nl;
return 0;
}
// Breathe In, Breathe Out