#include <bits/stdc++.h>
#include "insects.h"
std::bitset<2000> in_machine;
int min_cardinality(int N)
{
move_inside(0);
in_machine[0] = 1;
int d = 1;
for (int i = 1; i < N; ++i)
{
move_inside(i);
if (press_button() > 1)
move_outside(i);
else
++d, in_machine[i] = 1;
}
while (1)
{
int const bound = N / d;
std::vector<int> moved;
int inside = in_machine.count();
for (int i = 0; i < N && inside < d * bound; ++i)
if (!in_machine[i])
{
move_inside(i);
if (press_button() > bound)
move_outside(i);
else
in_machine[i] = 1, moved.push_back(i), ++inside;
}
if (inside == d * bound)
{
return bound;
}
else
{
N = inside;
for (auto const &i : moved)
in_machine[i] = 0, move_outside(i);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Incorrect |
6 ms |
304 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Incorrect |
6 ms |
304 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
30 ms |
280 KB |
Output is correct |
8 |
Correct |
20 ms |
208 KB |
Output is correct |
9 |
Correct |
21 ms |
288 KB |
Output is correct |
10 |
Incorrect |
85 ms |
296 KB |
Wrong answer. |
11 |
Halted |
0 ms |
0 KB |
- |