#include "insects.h"
#include <iostream>
#include <vector>
using namespace std;
// <|°_°|>
// JeanBombeur & M. Broccoli
// The hardest choices require the strongest wills
// What is better - to be born good, or to overcome your evil nature with great effort ?
const int MAX_INSECTS = (2000);
vector <int> Alive;
vector <int> In;
vector <int> Out;
int nbTypes = 0;
int nbInsects;
int Check() {
int sz = Alive.size();
int value = (sz + 2 * nbTypes - 1) / (2 * nbTypes);
In.clear();
Out.clear();
for (int a : Alive)
{
move_inside(a);
if (press_button() > value)
move_outside(a), Out.push_back(a);
else
In.push_back(a);
}
for (int a : In)
move_outside(a);
if ((int)In.size() == value * nbTypes)
{
Alive = Out;
return value;
}
Alive = In;
return 0;
}
int min_cardinality(int N) {
nbInsects = N;
int ans = 1;
for (int i = 0; i < nbInsects; i ++)
{
move_inside(i);
if (press_button() > 1)
move_outside(i), Alive.push_back(i);
else
nbTypes ++, In.push_back(i);
}
for (int a : In)
move_outside(a);
while ((int)Alive.size() >= nbTypes)
ans += Check();
return ans;
}
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
304 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
296 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
7 ms |
208 KB |
Output is correct |
17 |
Correct |
7 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
3 ms |
296 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
304 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
296 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
7 ms |
208 KB |
Output is correct |
17 |
Correct |
7 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
3 ms |
296 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
23 |
Correct |
25 ms |
300 KB |
Output is correct |
24 |
Correct |
8 ms |
296 KB |
Output is correct |
25 |
Correct |
22 ms |
208 KB |
Output is correct |
26 |
Correct |
29 ms |
284 KB |
Output is correct |
27 |
Correct |
24 ms |
428 KB |
Output is correct |
28 |
Correct |
10 ms |
208 KB |
Output is correct |
29 |
Correct |
26 ms |
304 KB |
Output is correct |
30 |
Correct |
21 ms |
308 KB |
Output is correct |
31 |
Correct |
32 ms |
208 KB |
Output is correct |
32 |
Correct |
26 ms |
300 KB |
Output is correct |
33 |
Correct |
24 ms |
208 KB |
Output is correct |
34 |
Correct |
26 ms |
328 KB |
Output is correct |
35 |
Correct |
29 ms |
208 KB |
Output is correct |
36 |
Correct |
20 ms |
308 KB |
Output is correct |
37 |
Correct |
21 ms |
336 KB |
Output is correct |
38 |
Correct |
26 ms |
208 KB |
Output is correct |
39 |
Correct |
21 ms |
208 KB |
Output is correct |
40 |
Correct |
14 ms |
300 KB |
Output is correct |
41 |
Correct |
8 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
57 ms |
304 KB |
Output is correct |
8 |
Correct |
18 ms |
208 KB |
Output is correct |
9 |
Correct |
43 ms |
300 KB |
Output is correct |
10 |
Correct |
46 ms |
308 KB |
Output is correct |
11 |
Correct |
41 ms |
312 KB |
Output is correct |
12 |
Correct |
26 ms |
208 KB |
Output is correct |
13 |
Correct |
27 ms |
296 KB |
Output is correct |
14 |
Correct |
46 ms |
296 KB |
Output is correct |
15 |
Correct |
51 ms |
296 KB |
Output is correct |
16 |
Correct |
51 ms |
304 KB |
Output is correct |
17 |
Correct |
61 ms |
300 KB |
Output is correct |
18 |
Correct |
59 ms |
304 KB |
Output is correct |
19 |
Correct |
47 ms |
296 KB |
Output is correct |
20 |
Correct |
47 ms |
304 KB |
Output is correct |
21 |
Correct |
55 ms |
300 KB |
Output is correct |
22 |
Correct |
48 ms |
296 KB |
Output is correct |
23 |
Correct |
47 ms |
296 KB |
Output is correct |
24 |
Correct |
41 ms |
208 KB |
Output is correct |
25 |
Correct |
22 ms |
308 KB |
Output is correct |
26 |
Correct |
14 ms |
300 KB |
Output is correct |
27 |
Correct |
63 ms |
348 KB |
Output is correct |
28 |
Correct |
56 ms |
208 KB |
Output is correct |
29 |
Correct |
48 ms |
300 KB |
Output is correct |
30 |
Correct |
57 ms |
300 KB |
Output is correct |
31 |
Correct |
51 ms |
208 KB |
Output is correct |
32 |
Correct |
55 ms |
292 KB |
Output is correct |
33 |
Correct |
47 ms |
296 KB |
Output is correct |
34 |
Correct |
44 ms |
208 KB |
Output is correct |
35 |
Correct |
52 ms |
300 KB |
Output is correct |
36 |
Correct |
55 ms |
316 KB |
Output is correct |
37 |
Correct |
44 ms |
296 KB |
Output is correct |
38 |
Correct |
23 ms |
308 KB |
Output is correct |
39 |
Correct |
49 ms |
292 KB |
Output is correct |
40 |
Correct |
52 ms |
416 KB |
Output is correct |
41 |
Correct |
44 ms |
308 KB |
Output is correct |
42 |
Correct |
54 ms |
328 KB |
Output is correct |
43 |
Correct |
13 ms |
208 KB |
Output is correct |
44 |
Correct |
19 ms |
428 KB |
Output is correct |
45 |
Correct |
63 ms |
292 KB |
Output is correct |
46 |
Correct |
28 ms |
292 KB |
Output is correct |
47 |
Correct |
27 ms |
208 KB |
Output is correct |
48 |
Correct |
22 ms |
308 KB |
Output is correct |