#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
deque<int> act, nex, in;
int getMin(int nbType) {
int n = act.size();
if(nbType == 1)
return n;
if(nbType > n)
return 0;
int del = (int)ceil(0.5 * (double)n / (double)nbType);
for(int i = 0; i < n; i++) {
move_inside(act[i]);
if(press_button() == del+1) {
move_outside(act[i]);
nex.push_back(act[i]);
} else {
in.push_back(act[i]);
}
}
if((int)in.size() == del * nbType) {
swap(act, nex);
for(int i : in)
move_outside(i);
in.clear();
nex.clear();
return del + getMin(nbType);
}
for(int i : in)
move_outside(i);
deque<int> repr, garde;
for(int i : nex) {
move_inside(i);
if(press_button() == 1) {
repr.push_back(i);
} else {
move_outside(i);
}
}
for(int i : in) {
move_inside(i);
if(press_button() == 1) {
garde.push_back(i);
}
move_outside(i);
}
for(int i : repr)
move_outside(i);
swap(garde, act);
garde.clear();
nex.clear();
in.clear();
return getMin(nbType - (int)repr.size());
}
int min_cardinality(int N) {
int nbType = 0;
for(int i = 0; i < N; i++)
act.push_back(i);
for(int i = 0; i < N; i++) {
move_inside(i);
if(press_button() == 2) {
move_outside(i);
nex.push_back(i);
} else {
nbType++;
in.push_back(i);
}
}
for(int i : in)
move_outside(i);
swap(act, nex);
nex.clear();
in.clear();
return getMin(nbType) + 1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
7 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
7 ms |
208 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
336 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
7 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
7 ms |
208 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
336 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
10 ms |
304 KB |
Output is correct |
24 |
Correct |
10 ms |
208 KB |
Output is correct |
25 |
Correct |
21 ms |
208 KB |
Output is correct |
26 |
Correct |
28 ms |
208 KB |
Output is correct |
27 |
Correct |
25 ms |
208 KB |
Output is correct |
28 |
Correct |
10 ms |
304 KB |
Output is correct |
29 |
Correct |
18 ms |
292 KB |
Output is correct |
30 |
Correct |
21 ms |
208 KB |
Output is correct |
31 |
Correct |
24 ms |
208 KB |
Output is correct |
32 |
Correct |
12 ms |
312 KB |
Output is correct |
33 |
Correct |
24 ms |
208 KB |
Output is correct |
34 |
Correct |
32 ms |
208 KB |
Output is correct |
35 |
Correct |
29 ms |
208 KB |
Output is correct |
36 |
Correct |
18 ms |
208 KB |
Output is correct |
37 |
Correct |
28 ms |
208 KB |
Output is correct |
38 |
Correct |
23 ms |
208 KB |
Output is correct |
39 |
Correct |
34 ms |
208 KB |
Output is correct |
40 |
Correct |
22 ms |
208 KB |
Output is correct |
41 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
13 ms |
308 KB |
Output is correct |
8 |
Correct |
20 ms |
312 KB |
Output is correct |
9 |
Correct |
45 ms |
312 KB |
Output is correct |
10 |
Correct |
48 ms |
304 KB |
Output is correct |
11 |
Correct |
34 ms |
208 KB |
Output is correct |
12 |
Correct |
33 ms |
208 KB |
Output is correct |
13 |
Correct |
54 ms |
312 KB |
Output is correct |
14 |
Correct |
47 ms |
300 KB |
Output is correct |
15 |
Correct |
57 ms |
336 KB |
Output is correct |
16 |
Correct |
57 ms |
208 KB |
Output is correct |
17 |
Correct |
52 ms |
304 KB |
Output is correct |
18 |
Correct |
56 ms |
208 KB |
Output is correct |
19 |
Correct |
54 ms |
208 KB |
Output is correct |
20 |
Correct |
52 ms |
300 KB |
Output is correct |
21 |
Correct |
50 ms |
208 KB |
Output is correct |
22 |
Correct |
53 ms |
308 KB |
Output is correct |
23 |
Correct |
40 ms |
308 KB |
Output is correct |
24 |
Correct |
61 ms |
208 KB |
Output is correct |
25 |
Correct |
40 ms |
292 KB |
Output is correct |
26 |
Correct |
19 ms |
208 KB |
Output is correct |
27 |
Correct |
59 ms |
208 KB |
Output is correct |
28 |
Correct |
54 ms |
312 KB |
Output is correct |
29 |
Correct |
49 ms |
308 KB |
Output is correct |
30 |
Correct |
57 ms |
304 KB |
Output is correct |
31 |
Correct |
53 ms |
308 KB |
Output is correct |
32 |
Correct |
48 ms |
312 KB |
Output is correct |
33 |
Correct |
54 ms |
304 KB |
Output is correct |
34 |
Correct |
43 ms |
304 KB |
Output is correct |
35 |
Correct |
56 ms |
336 KB |
Output is correct |
36 |
Correct |
63 ms |
208 KB |
Output is correct |
37 |
Correct |
48 ms |
296 KB |
Output is correct |
38 |
Correct |
57 ms |
308 KB |
Output is correct |
39 |
Correct |
44 ms |
424 KB |
Output is correct |
40 |
Correct |
45 ms |
304 KB |
Output is correct |
41 |
Correct |
41 ms |
208 KB |
Output is correct |
42 |
Correct |
40 ms |
208 KB |
Output is correct |
43 |
Partially correct |
13 ms |
208 KB |
Output is partially correct |
44 |
Partially correct |
52 ms |
208 KB |
Output is partially correct |
45 |
Correct |
54 ms |
312 KB |
Output is correct |
46 |
Correct |
20 ms |
316 KB |
Output is correct |
47 |
Correct |
33 ms |
208 KB |
Output is correct |
48 |
Correct |
31 ms |
312 KB |
Output is correct |