# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799732 | 2023-07-31T21:34:39 Z | rnl42 | Rarest Insects (IOI22_insects) | C++17 | 59 ms | 392 KB |
#include "insects.h" #include <vector> #include <iostream> #include <random> #include <algorithm> #include <numeric> using namespace std; int N, W; vector<bool> deleted; int remaining; int get_width() { int ret = 0; for (int i = 0; i < N; i++) { move_inside(i); if (press_button() >= 2) { move_outside(i); } else { deleted[i] = true; ret++; } } return ret; } int min_cardinality(int _N) { N = _N; deleted.resize(N); W = get_width(); remaining = N-W; int mini = 1, maxi = N/W; int minh = 1, maxh = N-W+1; if (W == 1) mini = N; vector<int> order(N); mt19937 rng(42); while (mini != maxi) { int mid = maxi-mini > 5 ? (mini+maxi-1>>1)+rng()%3 : (mini+maxi+1)>>1; vector<int> in_machine; vector<int> out_machine; for (int i = 0; i < N; i++) { if (!deleted[i]) { move_inside(i); if (press_button() > mid) { move_outside(i); out_machine.push_back(i); } else { in_machine.push_back(i); } } } if ((int)in_machine.size() == W*(mid-minh)) { for (int i : in_machine) { deleted[i] = true; remaining--; } mini = mid; minh = mid; } else { for (int i : out_machine) { deleted[i] = true; remaining--; } for (int i : in_machine) { move_outside(i); } maxi = mid-1; maxh = mid; } } return mini; }
Compilation message
# | 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 | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 4 ms | 208 KB | Output is correct |
9 | Correct | 3 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 | 300 KB | Output is correct |
13 | Correct | 5 ms | 208 KB | Output is correct |
14 | Correct | 5 ms | 304 KB | Output is correct |
15 | Correct | 5 ms | 304 KB | Output is correct |
16 | Correct | 5 ms | 304 KB | Output is correct |
17 | Correct | 6 ms | 208 KB | Output is correct |
18 | Correct | 4 ms | 208 KB | Output is correct |
19 | Correct | 6 ms | 208 KB | Output is correct |
20 | Correct | 4 ms | 208 KB | Output is correct |
21 | Correct | 2 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 | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 4 ms | 208 KB | Output is correct |
9 | Correct | 3 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 | 300 KB | Output is correct |
13 | Correct | 5 ms | 208 KB | Output is correct |
14 | Correct | 5 ms | 304 KB | Output is correct |
15 | Correct | 5 ms | 304 KB | Output is correct |
16 | Correct | 5 ms | 304 KB | Output is correct |
17 | Correct | 6 ms | 208 KB | Output is correct |
18 | Correct | 4 ms | 208 KB | Output is correct |
19 | Correct | 6 ms | 208 KB | Output is correct |
20 | Correct | 4 ms | 208 KB | Output is correct |
21 | Correct | 2 ms | 208 KB | Output is correct |
22 | Correct | 2 ms | 208 KB | Output is correct |
23 | Correct | 4 ms | 296 KB | Output is correct |
24 | Correct | 8 ms | 208 KB | Output is correct |
25 | Correct | 26 ms | 208 KB | Output is correct |
26 | Correct | 25 ms | 300 KB | Output is correct |
27 | Correct | 16 ms | 308 KB | Output is correct |
28 | Correct | 9 ms | 208 KB | Output is correct |
29 | Correct | 18 ms | 300 KB | Output is correct |
30 | Correct | 25 ms | 292 KB | Output is correct |
31 | Correct | 25 ms | 208 KB | Output is correct |
32 | Correct | 25 ms | 304 KB | Output is correct |
33 | Correct | 14 ms | 300 KB | Output is correct |
34 | Correct | 21 ms | 284 KB | Output is correct |
35 | Correct | 26 ms | 208 KB | Output is correct |
36 | Correct | 20 ms | 300 KB | Output is correct |
37 | Correct | 25 ms | 208 KB | Output is correct |
38 | Correct | 18 ms | 296 KB | Output is correct |
39 | Correct | 20 ms | 300 KB | Output is correct |
40 | Correct | 11 ms | 288 KB | Output is correct |
41 | Correct | 9 ms | 304 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 | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 18 ms | 208 KB | Output is correct |
8 | Correct | 14 ms | 292 KB | Output is correct |
9 | Correct | 47 ms | 292 KB | Output is correct |
10 | Correct | 40 ms | 292 KB | Output is correct |
11 | Correct | 35 ms | 296 KB | Output is correct |
12 | Correct | 26 ms | 296 KB | Output is correct |
13 | Correct | 20 ms | 312 KB | Output is correct |
14 | Correct | 49 ms | 208 KB | Output is correct |
15 | Correct | 53 ms | 280 KB | Output is correct |
16 | Correct | 33 ms | 208 KB | Output is correct |
17 | Correct | 38 ms | 300 KB | Output is correct |
18 | Correct | 34 ms | 284 KB | Output is correct |
19 | Correct | 44 ms | 280 KB | Output is correct |
20 | Correct | 51 ms | 208 KB | Output is correct |
21 | Partially correct | 49 ms | 296 KB | Output is partially correct |
22 | Correct | 59 ms | 296 KB | Output is correct |
23 | Correct | 43 ms | 320 KB | Output is correct |
24 | Correct | 37 ms | 292 KB | Output is correct |
25 | Correct | 22 ms | 296 KB | Output is correct |
26 | Correct | 17 ms | 208 KB | Output is correct |
27 | Correct | 24 ms | 300 KB | Output is correct |
28 | Correct | 49 ms | 280 KB | Output is correct |
29 | Correct | 47 ms | 292 KB | Output is correct |
30 | Correct | 38 ms | 284 KB | Output is correct |
31 | Correct | 55 ms | 296 KB | Output is correct |
32 | Correct | 43 ms | 304 KB | Output is correct |
33 | Correct | 34 ms | 208 KB | Output is correct |
34 | Correct | 36 ms | 300 KB | Output is correct |
35 | Correct | 48 ms | 280 KB | Output is correct |
36 | Correct | 49 ms | 284 KB | Output is correct |
37 | Partially correct | 50 ms | 296 KB | Output is partially correct |
38 | Partially correct | 55 ms | 392 KB | Output is partially correct |
39 | Correct | 44 ms | 296 KB | Output is correct |
40 | Correct | 49 ms | 300 KB | Output is correct |
41 | Correct | 45 ms | 280 KB | Output is correct |
42 | Correct | 47 ms | 208 KB | Output is correct |
43 | Correct | 9 ms | 208 KB | Output is correct |
44 | Correct | 39 ms | 284 KB | Output is correct |
45 | Correct | 39 ms | 292 KB | Output is correct |
46 | Correct | 20 ms | 296 KB | Output is correct |
47 | Correct | 26 ms | 296 KB | Output is correct |
48 | Correct | 20 ms | 292 KB | Output is correct |