Submission #1080676

# Submission time Handle Problem Language Result Execution time Memory
1080676 2024-08-29T12:20:37 Z asdasdqwer Rarest Insects (IOI22_insects) C++17
10 / 100
277 ms 600 KB
#include "insects.h"

#include <bits/stdc++.h>
using namespace std;

int one(int n, vector<int> &idx) {
    vector<bool> vis(n, false);
    for (auto &x:idx) {
        vis[x]=true;
    }
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    vector<int> rd;
    for (int i=0;i<n;i++) {
        rd.push_back(i);
    }

    shuffle(rd.begin(), rd.end(), rng);

    int mn = 1e9;
    int sm = 0;
    idx.pop_back();

    for (auto &x:idx) {
        int sz=1;
        move_inside(x);
        for (int i:rd) {
            if (vis[i]) continue;
            move_inside(i);
            
            if (press_button() == 2) {
                vis[i]=true;
                sz++;
            }

            move_outside(i);
        }

        if (sz == 1) {
            return sz;
        }

        mn = min(mn, sz);
        sm += sz;

        move_outside(x);
    }

    return min(mn, n-sm);
}

// int two(int n, vector<int> &idx) {

// }

int min_cardinality(int N) {
    // first all distinct
    vector<int> idx = {0};
    move_inside(0);
    int sz = 1;
    for (int i=1;i<N;i++) {
        move_inside(i);
        if (press_button() == 2) {
            move_outside(i);
        }

        else {
            sz++;
            idx.push_back(i);
        }
    }

    if (sz == N) {
        return 1;
    }

    if (sz == 1) {
        return N;
    }

    for (int i=0;i<sz;i++) {
        move_outside(idx[i]);
    }

    return one(N, idx);


}
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 10 ms 436 KB Output is correct
9 Correct 5 ms 432 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 9 ms 440 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 8 ms 344 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 9 ms 344 KB Output is correct
20 Correct 12 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 10 ms 436 KB Output is correct
9 Correct 5 ms 432 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 9 ms 440 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 8 ms 344 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 9 ms 344 KB Output is correct
20 Correct 12 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 3 ms 344 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 92 ms 344 KB Output is correct
26 Correct 110 ms 592 KB Output is correct
27 Correct 7 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 17 ms 344 KB Output is correct
30 Correct 118 ms 436 KB Output is correct
31 Correct 19 ms 600 KB Output is correct
32 Correct 36 ms 344 KB Output is correct
33 Correct 38 ms 344 KB Output is correct
34 Correct 47 ms 436 KB Output is correct
35 Correct 66 ms 344 KB Output is correct
36 Correct 63 ms 436 KB Output is correct
37 Correct 151 ms 344 KB Output is correct
38 Incorrect 277 ms 344 KB Too many queries.
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 10 ms 444 KB Output is correct
9 Incorrect 244 ms 344 KB Too many queries.
10 Halted 0 ms 0 KB -