#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int min_cardinality(int N) {
n = N;
vector<int> v;
set<int> in, out;
for(int i=0; i<n; i++){
move_inside(i);
v.push_back(i);
if(press_button()>=2){
move_outside(i);
v.pop_back();
out.insert(i);
}
}
mt19937 mt(4732012);
int lb = 0, rb = n / v.size();
while(lb<rb){
int mb = (lb+rb+1)/2;
vector<int> order(out.begin(), out.end()), last;
shuffle(order.begin(), order.end(), mt);
for(auto x:order){
if(v.size()*mb==in.size())
break;
out.extract(x);
in.insert(x);
last.push_back(x);
move_inside(x);
if(press_button()>mb+1){
move_outside(x);
in.extract(x);
out.insert(x);
last.pop_back();
}
}
if(v.size()*mb==in.size()){
lb=mb;
}else{
rb=mb-1;
for(auto x:last){
move_outside(x);
in.extract(x);
out.insert(x);
}
}
}
return lb+1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
600 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
7 ms |
600 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
600 KB |
Output is correct |
13 |
Correct |
4 ms |
1108 KB |
Output is correct |
14 |
Correct |
2 ms |
600 KB |
Output is correct |
15 |
Correct |
2 ms |
600 KB |
Output is correct |
16 |
Correct |
3 ms |
600 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
4 ms |
700 KB |
Output is correct |
19 |
Correct |
4 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
600 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
600 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
7 ms |
600 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
600 KB |
Output is correct |
13 |
Correct |
4 ms |
1108 KB |
Output is correct |
14 |
Correct |
2 ms |
600 KB |
Output is correct |
15 |
Correct |
2 ms |
600 KB |
Output is correct |
16 |
Correct |
3 ms |
600 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
4 ms |
700 KB |
Output is correct |
19 |
Correct |
4 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
600 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
10 ms |
1232 KB |
Output is correct |
24 |
Correct |
4 ms |
600 KB |
Output is correct |
25 |
Correct |
13 ms |
936 KB |
Output is correct |
26 |
Correct |
17 ms |
856 KB |
Output is correct |
27 |
Correct |
49 ms |
856 KB |
Output is correct |
28 |
Correct |
7 ms |
1112 KB |
Output is correct |
29 |
Correct |
49 ms |
1220 KB |
Output is correct |
30 |
Correct |
28 ms |
856 KB |
Output is correct |
31 |
Correct |
10 ms |
864 KB |
Output is correct |
32 |
Correct |
11 ms |
956 KB |
Output is correct |
33 |
Correct |
14 ms |
732 KB |
Output is correct |
34 |
Correct |
12 ms |
1208 KB |
Output is correct |
35 |
Correct |
13 ms |
856 KB |
Output is correct |
36 |
Correct |
14 ms |
488 KB |
Output is correct |
37 |
Correct |
16 ms |
1112 KB |
Output is correct |
38 |
Correct |
16 ms |
1112 KB |
Output is correct |
39 |
Correct |
11 ms |
856 KB |
Output is correct |
40 |
Correct |
6 ms |
1112 KB |
Output is correct |
41 |
Correct |
10 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
1368 KB |
Output is correct |
8 |
Correct |
9 ms |
856 KB |
Output is correct |
9 |
Correct |
20 ms |
1224 KB |
Output is correct |
10 |
Partially correct |
46 ms |
1008 KB |
Output is partially correct |
11 |
Partially correct |
94 ms |
880 KB |
Output is partially correct |
12 |
Correct |
12 ms |
608 KB |
Output is correct |
13 |
Partially correct |
93 ms |
980 KB |
Output is partially correct |
14 |
Partially correct |
64 ms |
1460 KB |
Output is partially correct |
15 |
Correct |
21 ms |
872 KB |
Output is correct |
16 |
Correct |
21 ms |
1368 KB |
Output is correct |
17 |
Correct |
23 ms |
952 KB |
Output is correct |
18 |
Correct |
30 ms |
600 KB |
Output is correct |
19 |
Correct |
25 ms |
1360 KB |
Output is correct |
20 |
Correct |
29 ms |
1140 KB |
Output is correct |
21 |
Partially correct |
38 ms |
752 KB |
Output is partially correct |
22 |
Partially correct |
33 ms |
996 KB |
Output is partially correct |
23 |
Partially correct |
32 ms |
1112 KB |
Output is partially correct |
24 |
Correct |
23 ms |
1388 KB |
Output is correct |
25 |
Correct |
19 ms |
1112 KB |
Output is correct |
26 |
Correct |
16 ms |
928 KB |
Output is correct |
27 |
Correct |
30 ms |
880 KB |
Output is correct |
28 |
Correct |
20 ms |
1216 KB |
Output is correct |
29 |
Correct |
29 ms |
1108 KB |
Output is correct |
30 |
Correct |
22 ms |
956 KB |
Output is correct |
31 |
Partially correct |
30 ms |
852 KB |
Output is partially correct |
32 |
Partially correct |
34 ms |
1388 KB |
Output is partially correct |
33 |
Partially correct |
41 ms |
732 KB |
Output is partially correct |
34 |
Partially correct |
52 ms |
916 KB |
Output is partially correct |
35 |
Correct |
23 ms |
1264 KB |
Output is correct |
36 |
Correct |
23 ms |
1104 KB |
Output is correct |
37 |
Partially correct |
47 ms |
856 KB |
Output is partially correct |
38 |
Partially correct |
35 ms |
976 KB |
Output is partially correct |
39 |
Correct |
20 ms |
892 KB |
Output is correct |
40 |
Correct |
25 ms |
1124 KB |
Output is correct |
41 |
Correct |
26 ms |
996 KB |
Output is correct |
42 |
Correct |
33 ms |
1364 KB |
Output is correct |
43 |
Partially correct |
19 ms |
344 KB |
Output is partially correct |
44 |
Partially correct |
88 ms |
884 KB |
Output is partially correct |
45 |
Correct |
16 ms |
1384 KB |
Output is correct |
46 |
Correct |
13 ms |
860 KB |
Output is correct |
47 |
Correct |
18 ms |
692 KB |
Output is correct |
48 |
Correct |
13 ms |
856 KB |
Output is correct |