Submission #708804

# Submission time Handle Problem Language Result Execution time Memory
708804 2023-03-12T10:30:17 Z t6twotwo Rarest Insects (IOI22_insects) C++17
100 / 100
87 ms 304 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int min_cardinality(int n) {
    vector<bool> in(n);
    for (int i = 0; i < n; i++) {
        move_inside(i);
        if (press_button() == 2) move_outside(i);
        else in[i] = 1;
    }
    int type = 0;
    vector<bool> blocked(n);
    for (int i = 0; i < n; i++) {
        if (in[i]) {
            type++;
            blocked[i] = 1;
        }
    }
    int lo = 1, hi = n / type, cnt = type;
    while (lo < hi) {
        int x = (lo + hi + 1) / 2;
        vector<int> p(n);
        iota(p.begin(), p.end(), 0);
        random_shuffle(p.begin(), p.end());
        for (int i = 0; i < n; i++) {
            if (blocked[p[i]] || cnt == x * type) continue;
            move_inside(p[i]);
            if (press_button() == x + 1) move_outside(p[i]);
            else in[p[i]] = 1, cnt++;
        }
        int t = cnt;
        for (int i = 0; i < n; i++) {
            if (blocked[i]) continue;
            if (in[i]) {
                if (t == x * type) {
                    blocked[i] = 1;
                } else {
                    in[i] = 0;
                    cnt--;
                    move_outside(i);
                }
            } else if (t != x * type) {
                blocked[i] = 1;
            }
        }
        if (t == x * type) lo = x;
        else hi = t / type;
    }
    return lo;
}
# 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 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 5 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 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 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 5 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 23 ms 280 KB Output is correct
24 Correct 8 ms 208 KB Output is correct
25 Correct 26 ms 208 KB Output is correct
26 Correct 36 ms 208 KB Output is correct
27 Correct 16 ms 208 KB Output is correct
28 Correct 10 ms 208 KB Output is correct
29 Correct 29 ms 288 KB Output is correct
30 Correct 26 ms 208 KB Output is correct
31 Correct 28 ms 280 KB Output is correct
32 Correct 21 ms 208 KB Output is correct
33 Correct 12 ms 292 KB Output is correct
34 Correct 20 ms 208 KB Output is correct
35 Correct 16 ms 304 KB Output is correct
36 Correct 21 ms 208 KB Output is correct
37 Correct 25 ms 208 KB Output is correct
38 Correct 11 ms 300 KB Output is correct
39 Correct 25 ms 276 KB Output is correct
40 Correct 15 ms 208 KB Output is correct
41 Correct 10 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 0 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 1 ms 208 KB Output is correct
7 Correct 40 ms 208 KB Output is correct
8 Correct 16 ms 208 KB Output is correct
9 Correct 36 ms 208 KB Output is correct
10 Correct 50 ms 284 KB Output is correct
11 Correct 65 ms 292 KB Output is correct
12 Correct 23 ms 208 KB Output is correct
13 Correct 45 ms 208 KB Output is correct
14 Correct 50 ms 208 KB Output is correct
15 Correct 52 ms 208 KB Output is correct
16 Correct 41 ms 276 KB Output is correct
17 Correct 48 ms 280 KB Output is correct
18 Correct 87 ms 208 KB Output is correct
19 Correct 49 ms 284 KB Output is correct
20 Correct 46 ms 208 KB Output is correct
21 Correct 57 ms 280 KB Output is correct
22 Correct 57 ms 288 KB Output is correct
23 Correct 57 ms 276 KB Output is correct
24 Correct 59 ms 276 KB Output is correct
25 Correct 35 ms 280 KB Output is correct
26 Correct 11 ms 208 KB Output is correct
27 Correct 29 ms 280 KB Output is correct
28 Correct 21 ms 208 KB Output is correct
29 Correct 47 ms 280 KB Output is correct
30 Correct 50 ms 280 KB Output is correct
31 Correct 62 ms 276 KB Output is correct
32 Correct 55 ms 280 KB Output is correct
33 Correct 25 ms 208 KB Output is correct
34 Correct 39 ms 284 KB Output is correct
35 Correct 37 ms 208 KB Output is correct
36 Correct 41 ms 208 KB Output is correct
37 Correct 40 ms 284 KB Output is correct
38 Correct 82 ms 284 KB Output is correct
39 Correct 35 ms 208 KB Output is correct
40 Correct 48 ms 208 KB Output is correct
41 Correct 52 ms 296 KB Output is correct
42 Correct 53 ms 208 KB Output is correct
43 Correct 12 ms 208 KB Output is correct
44 Correct 32 ms 208 KB Output is correct
45 Correct 41 ms 208 KB Output is correct
46 Correct 20 ms 280 KB Output is correct
47 Correct 33 ms 208 KB Output is correct
48 Correct 32 ms 280 KB Output is correct