#include "insects.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int min_cardinality(int n){
vector<int> a(n);
iota(a.begin(),a.end(),0);
random_shuffle(a.begin(),a.end());
int type = 0;
vector<int> in,out,in_temp,out_temp;
for(int i=0;i<n;i++){
move_inside(a[i]);
if(press_button() > 1) move_outside(a[i]), out.pb(a[i]);
else type++, in.pb(a[i]);
}
int be = 1, ed = n/type;
while(be <= ed){
int mid = (be+ed)/2, cnt = in.size();
in_temp.clear(), out_temp.clear();
for(auto x : out){
if(cnt == mid * type){
out_temp.pb(x);
continue;
}
move_inside(x);
if(press_button() > mid) move_outside(x), out_temp.pb(x);
else cnt++, in_temp.pb(x);
}
if(cnt == mid * type){
be = mid+1;
for(auto x : in_temp) in.pb(x);
out = out_temp;
}
else{
ed = mid-1;
for(auto x : in_temp) move_outside(x);
out = in_temp;
}
}
return ed;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 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 |
5 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 |
4 ms |
300 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
208 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
308 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
6 ms |
300 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
3 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 |
1 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 |
5 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 |
4 ms |
300 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
208 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
308 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
6 ms |
300 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
23 |
Correct |
20 ms |
312 KB |
Output is correct |
24 |
Correct |
8 ms |
208 KB |
Output is correct |
25 |
Correct |
22 ms |
292 KB |
Output is correct |
26 |
Correct |
28 ms |
304 KB |
Output is correct |
27 |
Correct |
19 ms |
308 KB |
Output is correct |
28 |
Correct |
9 ms |
208 KB |
Output is correct |
29 |
Correct |
26 ms |
316 KB |
Output is correct |
30 |
Correct |
25 ms |
304 KB |
Output is correct |
31 |
Correct |
25 ms |
300 KB |
Output is correct |
32 |
Correct |
18 ms |
304 KB |
Output is correct |
33 |
Correct |
19 ms |
316 KB |
Output is correct |
34 |
Correct |
22 ms |
308 KB |
Output is correct |
35 |
Correct |
21 ms |
304 KB |
Output is correct |
36 |
Correct |
29 ms |
296 KB |
Output is correct |
37 |
Correct |
18 ms |
296 KB |
Output is correct |
38 |
Correct |
17 ms |
304 KB |
Output is correct |
39 |
Correct |
15 ms |
300 KB |
Output is correct |
40 |
Correct |
16 ms |
312 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 |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
22 ms |
308 KB |
Output is correct |
8 |
Correct |
28 ms |
312 KB |
Output is correct |
9 |
Correct |
49 ms |
424 KB |
Output is correct |
10 |
Correct |
65 ms |
304 KB |
Output is correct |
11 |
Correct |
39 ms |
312 KB |
Output is correct |
12 |
Correct |
31 ms |
328 KB |
Output is correct |
13 |
Correct |
56 ms |
312 KB |
Output is correct |
14 |
Correct |
47 ms |
312 KB |
Output is correct |
15 |
Correct |
40 ms |
308 KB |
Output is correct |
16 |
Correct |
48 ms |
316 KB |
Output is correct |
17 |
Correct |
36 ms |
300 KB |
Output is correct |
18 |
Correct |
43 ms |
436 KB |
Output is correct |
19 |
Correct |
51 ms |
308 KB |
Output is correct |
20 |
Correct |
45 ms |
328 KB |
Output is correct |
21 |
Correct |
58 ms |
312 KB |
Output is correct |
22 |
Correct |
50 ms |
308 KB |
Output is correct |
23 |
Correct |
33 ms |
320 KB |
Output is correct |
24 |
Correct |
33 ms |
424 KB |
Output is correct |
25 |
Correct |
32 ms |
312 KB |
Output is correct |
26 |
Correct |
16 ms |
304 KB |
Output is correct |
27 |
Correct |
56 ms |
300 KB |
Output is correct |
28 |
Correct |
49 ms |
208 KB |
Output is correct |
29 |
Correct |
21 ms |
316 KB |
Output is correct |
30 |
Correct |
39 ms |
308 KB |
Output is correct |
31 |
Correct |
61 ms |
300 KB |
Output is correct |
32 |
Correct |
49 ms |
428 KB |
Output is correct |
33 |
Correct |
38 ms |
312 KB |
Output is correct |
34 |
Correct |
46 ms |
304 KB |
Output is correct |
35 |
Correct |
58 ms |
320 KB |
Output is correct |
36 |
Correct |
52 ms |
316 KB |
Output is correct |
37 |
Correct |
53 ms |
436 KB |
Output is correct |
38 |
Correct |
44 ms |
304 KB |
Output is correct |
39 |
Correct |
47 ms |
312 KB |
Output is correct |
40 |
Correct |
32 ms |
312 KB |
Output is correct |
41 |
Correct |
26 ms |
304 KB |
Output is correct |
42 |
Correct |
51 ms |
312 KB |
Output is correct |
43 |
Correct |
11 ms |
304 KB |
Output is correct |
44 |
Correct |
39 ms |
328 KB |
Output is correct |
45 |
Correct |
31 ms |
312 KB |
Output is correct |
46 |
Correct |
20 ms |
308 KB |
Output is correct |
47 |
Correct |
31 ms |
308 KB |
Output is correct |
48 |
Correct |
26 ms |
316 KB |
Output is correct |