#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int All_type[2000]={0};
int Box[2000]={0};
int Check[2000]={0};
int All_possible[2000];
int Total_N;
int level_1;
int check(int Num){
//cout<<Total_N<<"Total_N"<<endl;
int tmp;
for(int j=0;j<Total_N;j++){
//cout<<"All_possible "<<All_possible[j]<<" Check "<<Check[j]<<endl;
if(All_possible[j] && !Check[j]){
//cout<<j<<endl;
move_inside(j);
tmp=press_button();
if(tmp>Num){
move_outside(j);
}
else{
//now_active
Check[j]=2;
}
}
}
int Count=0;
for(int j=0;j<Total_N;j++){
if(Check[j]) {
Count++;
}
}
if(Count<level_1*Num){
for(int j=0;j<Total_N;j++){
if(Check[j]==2){
move_outside(j);
Check[j]=0;
}
else if(!Check[j]) All_possible[j]=0;
}
return 0;
}
for(int j=0;j<Total_N;j++){
if(Check[j]==2){
Check[j]=1;
}
}
return 1;
}
int min_cardinality(int N){
Total_N=N;
for(int j=0;j<N;j++){
All_possible[j]=1;
}
for(int j=0;j<N;j++){
int tmp;
if(!All_type[j]){
move_inside(j);
tmp=press_button();
if(tmp>1){
move_outside(j);
}
else{
Check[j]=1;
}
}
}
int Count=0;
for(int j=0;j<N;j++){
if(Check[j]==1) {
move_outside(j);
Check[j]=0;
Count++;
}
}
level_1=Count;
//binary_search
int L=1,R=N/level_1;
while(L!=R){
if((R-L)<=2){
if(check(L+1)){
if(check(L+2)) return L+2;
return L+1;
}
return L;
}
int M=(L+R)/2;
if(check(M)) L=M;
else R=M+1;
}
return L;
}
# |
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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
304 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 |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
11 ms |
208 KB |
Output is correct |
18 |
Correct |
7 ms |
304 KB |
Output is correct |
19 |
Correct |
7 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 |
2 ms |
208 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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
304 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 |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
11 ms |
208 KB |
Output is correct |
18 |
Correct |
7 ms |
304 KB |
Output is correct |
19 |
Correct |
7 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 |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
29 ms |
300 KB |
Output is correct |
24 |
Correct |
11 ms |
308 KB |
Output is correct |
25 |
Correct |
27 ms |
296 KB |
Output is correct |
26 |
Correct |
24 ms |
208 KB |
Output is correct |
27 |
Correct |
17 ms |
208 KB |
Output is correct |
28 |
Correct |
7 ms |
208 KB |
Output is correct |
29 |
Correct |
22 ms |
208 KB |
Output is correct |
30 |
Correct |
23 ms |
208 KB |
Output is correct |
31 |
Correct |
21 ms |
288 KB |
Output is correct |
32 |
Correct |
35 ms |
292 KB |
Output is correct |
33 |
Correct |
24 ms |
288 KB |
Output is correct |
34 |
Correct |
20 ms |
296 KB |
Output is correct |
35 |
Correct |
21 ms |
288 KB |
Output is correct |
36 |
Correct |
25 ms |
292 KB |
Output is correct |
37 |
Correct |
30 ms |
208 KB |
Output is correct |
38 |
Correct |
44 ms |
292 KB |
Output is correct |
39 |
Correct |
35 ms |
292 KB |
Output is correct |
40 |
Correct |
19 ms |
208 KB |
Output is correct |
41 |
Correct |
10 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
62 ms |
292 KB |
Output is correct |
8 |
Correct |
15 ms |
208 KB |
Output is correct |
9 |
Partially correct |
45 ms |
292 KB |
Output is partially correct |
10 |
Correct |
63 ms |
292 KB |
Output is correct |
11 |
Correct |
27 ms |
220 KB |
Output is correct |
12 |
Correct |
18 ms |
416 KB |
Output is correct |
13 |
Correct |
35 ms |
292 KB |
Output is correct |
14 |
Partially correct |
61 ms |
208 KB |
Output is partially correct |
15 |
Correct |
41 ms |
296 KB |
Output is correct |
16 |
Correct |
38 ms |
296 KB |
Output is correct |
17 |
Correct |
34 ms |
292 KB |
Output is correct |
18 |
Correct |
26 ms |
296 KB |
Output is correct |
19 |
Correct |
59 ms |
292 KB |
Output is correct |
20 |
Correct |
63 ms |
292 KB |
Output is correct |
21 |
Correct |
60 ms |
208 KB |
Output is correct |
22 |
Partially correct |
56 ms |
548 KB |
Output is partially correct |
23 |
Correct |
40 ms |
328 KB |
Output is correct |
24 |
Correct |
22 ms |
304 KB |
Output is correct |
25 |
Correct |
33 ms |
316 KB |
Output is correct |
26 |
Correct |
17 ms |
208 KB |
Output is correct |
27 |
Partially correct |
50 ms |
296 KB |
Output is partially correct |
28 |
Partially correct |
66 ms |
292 KB |
Output is partially correct |
29 |
Partially correct |
50 ms |
292 KB |
Output is partially correct |
30 |
Partially correct |
42 ms |
304 KB |
Output is partially correct |
31 |
Correct |
67 ms |
308 KB |
Output is correct |
32 |
Correct |
49 ms |
208 KB |
Output is correct |
33 |
Partially correct |
48 ms |
296 KB |
Output is partially correct |
34 |
Partially correct |
56 ms |
332 KB |
Output is partially correct |
35 |
Partially correct |
30 ms |
300 KB |
Output is partially correct |
36 |
Partially correct |
53 ms |
296 KB |
Output is partially correct |
37 |
Correct |
41 ms |
296 KB |
Output is correct |
38 |
Correct |
43 ms |
296 KB |
Output is correct |
39 |
Partially correct |
37 ms |
296 KB |
Output is partially correct |
40 |
Partially correct |
59 ms |
300 KB |
Output is partially correct |
41 |
Partially correct |
55 ms |
208 KB |
Output is partially correct |
42 |
Partially correct |
55 ms |
208 KB |
Output is partially correct |
43 |
Correct |
11 ms |
208 KB |
Output is correct |
44 |
Correct |
36 ms |
208 KB |
Output is correct |
45 |
Correct |
61 ms |
292 KB |
Output is correct |
46 |
Correct |
43 ms |
208 KB |
Output is correct |
47 |
Correct |
29 ms |
208 KB |
Output is correct |
48 |
Correct |
32 ms |
208 KB |
Output is correct |