#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
const int N = 2e3 + 10;
int n;
bool bad[N] , dead[N];
bool check(int mid)
{
for(int i = 0 ; i < n ; i++) if(!dead[i])
{
bad[i] = false;
move_inside(i);
int val = press_button();
if(val > mid)
{
bad[i] = true;
move_outside(i);
}
}
for(int i = 0 ; i < n ; i++) if(!bad[i] && !dead[i])
move_outside(i);
bool flg = true;
vector <int> vec;
for(int i = 0 ; i < n ; i++) if(bad[i] && !dead[i])
{
flg = false;
move_inside(i);
int val = press_button();
if(val > 1)
move_outside(i);
else
vec.push_back(i);
}
if(flg)
return true;
for(int i = 0 ; i < n ; i++) if(!bad[i] && !dead[i])
{
move_inside(i);
int val = press_button();
if(val == 1)
{
flg = true;
}
else
{
bad[i] = true;
}
move_outside(i);
}
for(auto u : vec)
move_outside(u);
if(!flg)
return false;
for(int i = 0 ; i < n ; i++) if(bad[i])
dead[i] = true;
return flg;
}
int min_cardinality(int nn)
{
n = nn;
int low = 0 , high = n;
while(high - low > 1)
{
int mid = (low + high) >> 1;
if(check(mid))
high = mid;
else
low = mid;
}
return high;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
18 ms |
344 KB |
Output is correct |
7 |
Correct |
8 ms |
344 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
344 KB |
Output is correct |
14 |
Correct |
9 ms |
344 KB |
Output is correct |
15 |
Correct |
7 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
344 KB |
Output is correct |
18 |
Correct |
5 ms |
596 KB |
Output is correct |
19 |
Correct |
7 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
7 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
18 ms |
344 KB |
Output is correct |
7 |
Correct |
8 ms |
344 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Correct |
6 ms |
344 KB |
Output is correct |
14 |
Correct |
9 ms |
344 KB |
Output is correct |
15 |
Correct |
7 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
344 KB |
Output is correct |
18 |
Correct |
5 ms |
596 KB |
Output is correct |
19 |
Correct |
7 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
344 KB |
Output is correct |
21 |
Correct |
7 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
344 KB |
Output is correct |
23 |
Correct |
114 ms |
344 KB |
Output is correct |
24 |
Correct |
57 ms |
344 KB |
Output is correct |
25 |
Correct |
47 ms |
344 KB |
Output is correct |
26 |
Correct |
44 ms |
344 KB |
Output is correct |
27 |
Correct |
9 ms |
344 KB |
Output is correct |
28 |
Correct |
27 ms |
344 KB |
Output is correct |
29 |
Correct |
18 ms |
344 KB |
Output is correct |
30 |
Correct |
40 ms |
344 KB |
Output is correct |
31 |
Correct |
48 ms |
344 KB |
Output is correct |
32 |
Correct |
50 ms |
344 KB |
Output is correct |
33 |
Correct |
45 ms |
344 KB |
Output is correct |
34 |
Correct |
49 ms |
344 KB |
Output is correct |
35 |
Correct |
43 ms |
344 KB |
Output is correct |
36 |
Correct |
38 ms |
344 KB |
Output is correct |
37 |
Correct |
34 ms |
344 KB |
Output is correct |
38 |
Correct |
74 ms |
344 KB |
Output is correct |
39 |
Correct |
58 ms |
344 KB |
Output is correct |
40 |
Correct |
58 ms |
416 KB |
Output is correct |
41 |
Correct |
56 ms |
412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 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 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
7 |
Incorrect |
244 ms |
660 KB |
Too many queries. |
8 |
Halted |
0 ms |
0 KB |
- |