#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
const int N = 2e3 + 10;
int n;
bool bad[N];
bool check(int mid)
{
for(int i = 0 ; i < n ; 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])
move_outside(i);
for(int i = 0 ; i < n ; i++) if(bad[i])
{
move_inside(i);
int val = press_button();
if(val > 1)
move_outside(i);
}
bool flg = false;
for(int i = 0 ; i < n ; i++) if(!bad[i])
{
move_inside(i);
int val = press_button();
if(val == 1)
{
flg = true;
}
move_outside(i);
}
for(int i = 0 ; i < n ; i++) if(bad[i])
move_outside(i);
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 |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
13 ms |
344 KB |
Output is correct |
7 |
Correct |
12 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
596 KB |
Output is correct |
9 |
Correct |
15 ms |
344 KB |
Output is correct |
10 |
Correct |
16 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
344 KB |
Output is correct |
12 |
Correct |
12 ms |
344 KB |
Output is correct |
13 |
Correct |
13 ms |
344 KB |
Output is correct |
14 |
Correct |
14 ms |
344 KB |
Output is correct |
15 |
Correct |
14 ms |
344 KB |
Output is correct |
16 |
Correct |
13 ms |
344 KB |
Output is correct |
17 |
Correct |
11 ms |
340 KB |
Output is correct |
18 |
Correct |
17 ms |
344 KB |
Output is correct |
19 |
Correct |
13 ms |
344 KB |
Output is correct |
20 |
Correct |
13 ms |
344 KB |
Output is correct |
21 |
Correct |
14 ms |
344 KB |
Output is correct |
22 |
Correct |
17 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 |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
13 ms |
344 KB |
Output is correct |
7 |
Correct |
12 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
596 KB |
Output is correct |
9 |
Correct |
15 ms |
344 KB |
Output is correct |
10 |
Correct |
16 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
344 KB |
Output is correct |
12 |
Correct |
12 ms |
344 KB |
Output is correct |
13 |
Correct |
13 ms |
344 KB |
Output is correct |
14 |
Correct |
14 ms |
344 KB |
Output is correct |
15 |
Correct |
14 ms |
344 KB |
Output is correct |
16 |
Correct |
13 ms |
344 KB |
Output is correct |
17 |
Correct |
11 ms |
340 KB |
Output is correct |
18 |
Correct |
17 ms |
344 KB |
Output is correct |
19 |
Correct |
13 ms |
344 KB |
Output is correct |
20 |
Correct |
13 ms |
344 KB |
Output is correct |
21 |
Correct |
14 ms |
344 KB |
Output is correct |
22 |
Correct |
17 ms |
344 KB |
Output is correct |
23 |
Correct |
108 ms |
344 KB |
Output is correct |
24 |
Correct |
83 ms |
344 KB |
Output is correct |
25 |
Correct |
100 ms |
344 KB |
Output is correct |
26 |
Correct |
147 ms |
412 KB |
Output is correct |
27 |
Correct |
107 ms |
344 KB |
Output is correct |
28 |
Correct |
102 ms |
844 KB |
Output is correct |
29 |
Correct |
107 ms |
344 KB |
Output is correct |
30 |
Correct |
106 ms |
420 KB |
Output is correct |
31 |
Correct |
127 ms |
344 KB |
Output is correct |
32 |
Correct |
116 ms |
344 KB |
Output is correct |
33 |
Correct |
99 ms |
344 KB |
Output is correct |
34 |
Correct |
113 ms |
344 KB |
Output is correct |
35 |
Correct |
125 ms |
344 KB |
Output is correct |
36 |
Correct |
115 ms |
344 KB |
Output is correct |
37 |
Correct |
130 ms |
672 KB |
Output is correct |
38 |
Correct |
112 ms |
344 KB |
Output is correct |
39 |
Correct |
94 ms |
420 KB |
Output is correct |
40 |
Correct |
99 ms |
344 KB |
Output is correct |
41 |
Correct |
102 ms |
592 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 |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Partially correct |
0 ms |
344 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
7 |
Incorrect |
248 ms |
664 KB |
Too many queries. |
8 |
Halted |
0 ms |
0 KB |
- |