#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
bool inside[N];
set<int> items;
int n;
int min_cardinality(int _n) {
n = _n;
for (int i = 0; i < n; ++i) items.insert(i);
int types = 0;
for (int i = 0; i < n; ++i) {
inside[i] = 1;
move_inside(i);
++types;
if (press_button() == 2) {
inside[i] = 0;
move_outside(i);
--types;
}
}
for (int i = 0; i < n; ++i) if (inside[i]) {
inside[i] = 0;
move_outside(i);
}
int L = 1, R = n / types, res = 1;
while (L <= R) {
int mid = (L + R) >> 1;
set<int> turn;
int cnt = 0;
for (int i : items) {
if (!inside[i]) {
inside[i] = 1;
move_inside(i);
turn.insert(i);
if (press_button() > mid) {
inside[i] = 0;
move_outside(i);
turn.erase(i);
}
}
cnt += inside[i];
}
if (cnt == types * mid) {
res = mid;
L = mid + 1;
}
else {
set<int> nxt;
for (int i : items) if (inside[i]) nxt.insert(i);
for (int i : turn) {
inside[i] = 0;
move_outside(i);
}
items = nxt;
R = min((int)items.size() / types, mid - 1);
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
312 KB |
Output is correct |
10 |
Correct |
5 ms |
316 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
7 ms |
312 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
308 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
8 ms |
316 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
7 ms |
316 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
5 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
312 KB |
Output is correct |
10 |
Correct |
5 ms |
316 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
7 ms |
312 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
308 KB |
Output is correct |
15 |
Correct |
6 ms |
208 KB |
Output is correct |
16 |
Correct |
8 ms |
316 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
7 ms |
208 KB |
Output is correct |
20 |
Correct |
7 ms |
316 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
5 ms |
208 KB |
Output is correct |
23 |
Correct |
26 ms |
336 KB |
Output is correct |
24 |
Correct |
21 ms |
348 KB |
Output is correct |
25 |
Correct |
25 ms |
340 KB |
Output is correct |
26 |
Correct |
30 ms |
352 KB |
Output is correct |
27 |
Correct |
19 ms |
344 KB |
Output is correct |
28 |
Correct |
13 ms |
336 KB |
Output is correct |
29 |
Correct |
30 ms |
460 KB |
Output is correct |
30 |
Correct |
34 ms |
336 KB |
Output is correct |
31 |
Correct |
23 ms |
352 KB |
Output is correct |
32 |
Correct |
26 ms |
352 KB |
Output is correct |
33 |
Correct |
38 ms |
344 KB |
Output is correct |
34 |
Correct |
27 ms |
336 KB |
Output is correct |
35 |
Correct |
34 ms |
352 KB |
Output is correct |
36 |
Correct |
15 ms |
352 KB |
Output is correct |
37 |
Correct |
43 ms |
352 KB |
Output is correct |
38 |
Correct |
30 ms |
336 KB |
Output is correct |
39 |
Correct |
27 ms |
352 KB |
Output is correct |
40 |
Correct |
25 ms |
356 KB |
Output is correct |
41 |
Correct |
21 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
39 ms |
380 KB |
Output is correct |
8 |
Correct |
19 ms |
416 KB |
Output is correct |
9 |
Correct |
54 ms |
376 KB |
Output is correct |
10 |
Correct |
64 ms |
380 KB |
Output is correct |
11 |
Correct |
26 ms |
372 KB |
Output is correct |
12 |
Correct |
51 ms |
380 KB |
Output is correct |
13 |
Correct |
54 ms |
372 KB |
Output is correct |
14 |
Correct |
48 ms |
372 KB |
Output is correct |
15 |
Correct |
63 ms |
388 KB |
Output is correct |
16 |
Correct |
57 ms |
648 KB |
Output is correct |
17 |
Correct |
65 ms |
420 KB |
Output is correct |
18 |
Correct |
71 ms |
384 KB |
Output is correct |
19 |
Partially correct |
47 ms |
376 KB |
Output is partially correct |
20 |
Correct |
63 ms |
424 KB |
Output is correct |
21 |
Correct |
87 ms |
380 KB |
Output is correct |
22 |
Correct |
42 ms |
372 KB |
Output is correct |
23 |
Correct |
47 ms |
456 KB |
Output is correct |
24 |
Correct |
47 ms |
456 KB |
Output is correct |
25 |
Correct |
51 ms |
500 KB |
Output is correct |
26 |
Correct |
37 ms |
384 KB |
Output is correct |
27 |
Partially correct |
45 ms |
388 KB |
Output is partially correct |
28 |
Partially correct |
61 ms |
376 KB |
Output is partially correct |
29 |
Partially correct |
66 ms |
504 KB |
Output is partially correct |
30 |
Partially correct |
55 ms |
420 KB |
Output is partially correct |
31 |
Correct |
38 ms |
516 KB |
Output is correct |
32 |
Correct |
33 ms |
436 KB |
Output is correct |
33 |
Correct |
49 ms |
456 KB |
Output is correct |
34 |
Correct |
54 ms |
456 KB |
Output is correct |
35 |
Partially correct |
45 ms |
428 KB |
Output is partially correct |
36 |
Partially correct |
57 ms |
388 KB |
Output is partially correct |
37 |
Correct |
47 ms |
408 KB |
Output is correct |
38 |
Correct |
63 ms |
420 KB |
Output is correct |
39 |
Partially correct |
57 ms |
392 KB |
Output is partially correct |
40 |
Partially correct |
48 ms |
372 KB |
Output is partially correct |
41 |
Partially correct |
42 ms |
412 KB |
Output is partially correct |
42 |
Partially correct |
72 ms |
412 KB |
Output is partially correct |
43 |
Correct |
20 ms |
208 KB |
Output is correct |
44 |
Correct |
43 ms |
372 KB |
Output is correct |
45 |
Correct |
50 ms |
388 KB |
Output is correct |
46 |
Correct |
52 ms |
336 KB |
Output is correct |
47 |
Correct |
45 ms |
376 KB |
Output is correct |
48 |
Correct |
53 ms |
408 KB |
Output is correct |