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 <bits/stdc++.h>
#include "insects.h"
std::bitset<2000> in_machine, deleted;
int min_cardinality(int N)
{
int d = 0;
for (int i = 0; i < N; ++i)
{
move_inside(i);
if (press_button() > 1)
move_outside(i);
else
++d, in_machine[i] = 1;
}
int a = 1, b = N / d;
while (a < b)
{
int const mid = (a + b + 1) >> 1;
std::vector<int> moved;
int inside = in_machine.count();
for (int i = 0; i < N && inside < d * mid; ++i)
if (!deleted[i] && !in_machine[i])
{
move_inside(i);
if (press_button() > mid)
move_outside(i);
else
in_machine[i] = 1, moved.push_back(i), ++inside;
}
if (inside == d * mid)
{
a = mid;
}
else
{
b = mid - 1;
deleted |= ~in_machine;
for (auto const &i : moved)
in_machine[i] = 0, move_outside(i);
}
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |