# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1137719 | KaleemRazaSyed | COVID tests (CEOI24_covid) | C++20 | 944 ms | 456 KiB |
#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());
int n;
double p;
map<double, double> base;
bool ask(vector<bool> mask)
{
assert(mask.size() == (size_t)n);
std::string mask_str(n, ' ');
for (int i = 0; i < n; i++)
mask_str[i] = mask[i] ? '1' : '0';
printf("Q %s\n", mask_str.c_str());
fflush(stdout);
char answer;
scanf(" %c", &answer);
return answer == 'P';
}
vector<int> fig(vector<int> a)
{
if(a.empty()) return a;
vector<bool> mask(n, false);
vector<int> sol;
for(int i : a) mask[i] = true;
if(!ask(mask)) return sol;
if(a.size() == 1) return a;
vector<int> b;
double bp = 1.0 / ((double)a.size() - 1);
if(base.find(p) != base.end())
bp = 1 / base[p];
int c = ceil((a.size()) * bp);
c = min(c, (int)a.size() - 1);
for(int i = 0; i < a.size(); i++)
{
b.push_back(a[i]);
if(b.size() == c || i + 1 == a.size())
{
vector<int> solp = fig(b);
for(int x : solp)
sol.push_back(x);
b.clear();
}
}
return sol;
}
vector<bool> solve()
{
vector<int> idx(n);
iota(idx.begin(), idx.end(), 0);
for(int i = 0; i < n; i ++)
{
int j = rnd() % (i + 1);
swap(idx[i], idx[j]);
}
vector<bool> v(n, false);
vector<int> sol = fig(idx);
for(int i : sol)
v[i] = true;
return v;
}
int main()
{
int T;
scanf("%d %lf %d", &n, &p, &T);
base[0.001] = 1.5;
base[0.005256] = 2.1;
base[0.011546] = 2.4;
base[0.028545] = 2.7;
base[0.039856] = 3.2;
base[0.068648] = 3.5;
base[0.104571] = 4;
base[0.158765] = 5;
base[0.2] = 6;
for (int i = 0; i < T; i++) {
vector<bool> answer = solve();
assert(answer.size() == (size_t)n);
string answer_str(n, ' ');
for (int j = 0; j < n; j++)
answer_str[j] = answer[j] ? '1' : '0';
printf("A %s\n", answer_str.c_str());
fflush(stdout);
char verdict;
scanf(" %c", &verdict);
if (verdict == 'W')
exit(0);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |