#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 = mid - 1;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
7 ms |
320 KB |
Output is correct |
9 |
Correct |
6 ms |
308 KB |
Output is correct |
10 |
Correct |
5 ms |
312 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
312 KB |
Output is correct |
13 |
Correct |
3 ms |
208 KB |
Output is correct |
14 |
Correct |
8 ms |
320 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
7 ms |
308 KB |
Output is correct |
18 |
Correct |
6 ms |
312 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
5 ms |
312 KB |
Output is correct |
21 |
Correct |
5 ms |
320 KB |
Output is correct |
22 |
Correct |
5 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
7 ms |
320 KB |
Output is correct |
9 |
Correct |
6 ms |
308 KB |
Output is correct |
10 |
Correct |
5 ms |
312 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
312 KB |
Output is correct |
13 |
Correct |
3 ms |
208 KB |
Output is correct |
14 |
Correct |
8 ms |
320 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
7 ms |
308 KB |
Output is correct |
18 |
Correct |
6 ms |
312 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
5 ms |
312 KB |
Output is correct |
21 |
Correct |
5 ms |
320 KB |
Output is correct |
22 |
Correct |
5 ms |
208 KB |
Output is correct |
23 |
Correct |
31 ms |
344 KB |
Output is correct |
24 |
Correct |
17 ms |
348 KB |
Output is correct |
25 |
Correct |
27 ms |
348 KB |
Output is correct |
26 |
Correct |
30 ms |
344 KB |
Output is correct |
27 |
Correct |
27 ms |
340 KB |
Output is correct |
28 |
Correct |
20 ms |
348 KB |
Output is correct |
29 |
Correct |
15 ms |
344 KB |
Output is correct |
30 |
Correct |
39 ms |
472 KB |
Output is correct |
31 |
Correct |
31 ms |
456 KB |
Output is correct |
32 |
Correct |
20 ms |
352 KB |
Output is correct |
33 |
Correct |
28 ms |
356 KB |
Output is correct |
34 |
Correct |
44 ms |
336 KB |
Output is correct |
35 |
Correct |
36 ms |
336 KB |
Output is correct |
36 |
Correct |
27 ms |
368 KB |
Output is correct |
37 |
Correct |
27 ms |
336 KB |
Output is correct |
38 |
Correct |
15 ms |
476 KB |
Output is correct |
39 |
Correct |
31 ms |
344 KB |
Output is correct |
40 |
Correct |
25 ms |
352 KB |
Output is correct |
41 |
Correct |
22 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 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 |
63 ms |
380 KB |
Output is correct |
8 |
Correct |
33 ms |
372 KB |
Output is correct |
9 |
Correct |
59 ms |
380 KB |
Output is correct |
10 |
Correct |
58 ms |
424 KB |
Output is correct |
11 |
Correct |
42 ms |
336 KB |
Output is correct |
12 |
Correct |
46 ms |
412 KB |
Output is correct |
13 |
Correct |
60 ms |
456 KB |
Output is correct |
14 |
Correct |
49 ms |
380 KB |
Output is correct |
15 |
Correct |
60 ms |
420 KB |
Output is correct |
16 |
Correct |
70 ms |
424 KB |
Output is correct |
17 |
Correct |
60 ms |
456 KB |
Output is correct |
18 |
Correct |
56 ms |
428 KB |
Output is correct |
19 |
Partially correct |
67 ms |
376 KB |
Output is partially correct |
20 |
Correct |
62 ms |
520 KB |
Output is correct |
21 |
Correct |
44 ms |
404 KB |
Output is correct |
22 |
Correct |
62 ms |
420 KB |
Output is correct |
23 |
Correct |
44 ms |
456 KB |
Output is correct |
24 |
Correct |
62 ms |
456 KB |
Output is correct |
25 |
Correct |
44 ms |
392 KB |
Output is correct |
26 |
Correct |
38 ms |
396 KB |
Output is correct |
27 |
Partially correct |
59 ms |
336 KB |
Output is partially correct |
28 |
Partially correct |
61 ms |
400 KB |
Output is partially correct |
29 |
Partially correct |
42 ms |
420 KB |
Output is partially correct |
30 |
Partially correct |
59 ms |
400 KB |
Output is partially correct |
31 |
Correct |
71 ms |
376 KB |
Output is correct |
32 |
Correct |
48 ms |
376 KB |
Output is correct |
33 |
Correct |
50 ms |
376 KB |
Output is correct |
34 |
Correct |
63 ms |
424 KB |
Output is correct |
35 |
Partially correct |
68 ms |
424 KB |
Output is partially correct |
36 |
Partially correct |
52 ms |
424 KB |
Output is partially correct |
37 |
Correct |
64 ms |
392 KB |
Output is correct |
38 |
Correct |
60 ms |
412 KB |
Output is correct |
39 |
Partially correct |
69 ms |
388 KB |
Output is partially correct |
40 |
Partially correct |
104 ms |
372 KB |
Output is partially correct |
41 |
Partially correct |
63 ms |
384 KB |
Output is partially correct |
42 |
Partially correct |
71 ms |
388 KB |
Output is partially correct |
43 |
Correct |
10 ms |
336 KB |
Output is correct |
44 |
Correct |
56 ms |
368 KB |
Output is correct |
45 |
Correct |
59 ms |
336 KB |
Output is correct |
46 |
Correct |
41 ms |
496 KB |
Output is correct |
47 |
Correct |
57 ms |
392 KB |
Output is correct |
48 |
Correct |
59 ms |
392 KB |
Output is correct |