Submission #1092517

# Submission time Handle Problem Language Result Execution time Memory
1092517 2024-09-24T09:55:38 Z huyngo Rarest Insects (IOI22_insects) C++17
47.5 / 100
158 ms 1104 KB
#include "insects.h"
#include <bits/stdc++.h>  
using namespace std;
using ll = long long;
using i64 = long long;
void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char* x) { cerr << '"' << x << '"'; } void __print(const string& x) { cerr << '"' << x << '"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template<typename T, typename V> void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template<typename T> void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#define ln "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define ar array
int Bit(int mask, int b) { return (mask >> b) & 1; }
const ll base = 311, MOD = 998244353, M = 1e9 + 7, INF = 1e18;

int min_cardinality(int N) {
    set<int> T;
    auto add = [&](int x) { T.insert(x); move_inside(x); };
    auto del = [&](int x) { T.erase(x); move_outside(x); };
    auto reset = [&]() { auto clone = T; for (int x : clone) del(x); };

    for (int i = 0; i < N; ++i) {
        add(i);
        if (press_button() > 1)
            del(i);
    }
    int n_species = T.size();
    reset();

    int lo = 2, hi = N / n_species, res = 1;
    while (lo <= hi) {
        int md = (lo + hi) / 2;
        for (int i = 0; i < N; ++i) {
            add(i);
            if (press_button() > md)
                del(i);
        }
        int x = T.size();
        reset();
        if (x >= n_species * md) {
            res = md;
            lo = md + 1;
        }
        else
            hi = md - 1;
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
6 Correct 10 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 5 ms 448 KB Output is correct
9 Correct 5 ms 432 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 3 ms 436 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 7 ms 448 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
6 Correct 10 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 5 ms 448 KB Output is correct
9 Correct 5 ms 432 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 3 ms 436 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 7 ms 448 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 59 ms 344 KB Output is correct
24 Correct 10 ms 344 KB Output is correct
25 Correct 27 ms 612 KB Output is correct
26 Correct 30 ms 344 KB Output is correct
27 Correct 58 ms 600 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 44 ms 344 KB Output is correct
30 Correct 27 ms 344 KB Output is correct
31 Correct 57 ms 896 KB Output is correct
32 Correct 57 ms 600 KB Output is correct
33 Correct 57 ms 600 KB Output is correct
34 Correct 52 ms 436 KB Output is correct
35 Correct 37 ms 592 KB Output is correct
36 Correct 52 ms 600 KB Output is correct
37 Correct 33 ms 596 KB Output is correct
38 Correct 33 ms 600 KB Output is correct
39 Correct 18 ms 600 KB Output is correct
40 Correct 10 ms 600 KB Output is correct
41 Correct 5 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 Partially correct 1 ms 344 KB Output is partially correct
7 Partially correct 158 ms 788 KB Output is partially correct
8 Correct 11 ms 600 KB Output is correct
9 Partially correct 84 ms 728 KB Output is partially correct
10 Partially correct 96 ms 556 KB Output is partially correct
11 Partially correct 134 ms 600 KB Output is partially correct
12 Correct 17 ms 344 KB Output is correct
13 Partially correct 147 ms 436 KB Output is partially correct
14 Partially correct 63 ms 688 KB Output is partially correct
15 Partially correct 105 ms 680 KB Output is partially correct
16 Partially correct 99 ms 804 KB Output is partially correct
17 Partially correct 123 ms 464 KB Output is partially correct
18 Partially correct 115 ms 824 KB Output is partially correct
19 Partially correct 119 ms 428 KB Output is partially correct
20 Partially correct 90 ms 744 KB Output is partially correct
21 Partially correct 65 ms 800 KB Output is partially correct
22 Partially correct 76 ms 596 KB Output is partially correct
23 Partially correct 53 ms 1104 KB Output is partially correct
24 Correct 50 ms 444 KB Output is correct
25 Correct 28 ms 600 KB Output is correct
26 Correct 11 ms 344 KB Output is correct
27 Partially correct 81 ms 592 KB Output is partially correct
28 Partially correct 64 ms 456 KB Output is partially correct
29 Partially correct 86 ms 636 KB Output is partially correct
30 Partially correct 93 ms 764 KB Output is partially correct
31 Partially correct 85 ms 696 KB Output is partially correct
32 Partially correct 59 ms 748 KB Output is partially correct
33 Partially correct 57 ms 596 KB Output is partially correct
34 Partially correct 60 ms 592 KB Output is partially correct
35 Partially correct 84 ms 792 KB Output is partially correct
36 Partially correct 106 ms 688 KB Output is partially correct
37 Partially correct 66 ms 700 KB Output is partially correct
38 Partially correct 53 ms 556 KB Output is partially correct
39 Partially correct 64 ms 760 KB Output is partially correct
40 Partially correct 69 ms 592 KB Output is partially correct
41 Partially correct 85 ms 552 KB Output is partially correct
42 Partially correct 85 ms 584 KB Output is partially correct
43 Partially correct 17 ms 344 KB Output is partially correct
44 Partially correct 109 ms 344 KB Output is partially correct
45 Partially correct 141 ms 936 KB Output is partially correct
46 Correct 23 ms 856 KB Output is correct
47 Correct 26 ms 444 KB Output is correct
48 Correct 31 ms 508 KB Output is correct