# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1074695 | Nicolaikrob | Digital Circuit (IOI22_circuit) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
int min_cardinality(int N)
{
// Find the number of different insect types:
// Maximum number of insects with 1 being maximum
// Let that number be K
// Find another set of K numbers with 2 being the maximum
// Then 3 and 4 and so on untill it is no longer possible
// The grader is not adaptive:
vector<int> indicies(N);
iota(indicies.begin(), indicies.end(), 0);
mt19937 mt(time(0));
shuffle(indicies.begin(), indicies.end(), mt);
vector<int> in(N);
int k = 0;
for (int i = 0; i < N; i++)
{
move_inside(indicies[i]);
if (press_button() > 1)
{
move_outside(indicies[i]);
}
else
{
k++;
in[i] = 1;
}
}
int res = 1;
while (true)
{
int cnt = 0;
for (int i = 0; i < N && cnt < k; i++)
{
if (in[i]) continue;
move_inside(indicies[i]);
if (press_button() > res + 1)
{
move_outside(indicies[i]);
}
else
{
cnt++;
in[i] = 1;
}
}
if (cnt < k)
return res;
res++;
}
return res;
}