Submission #1074609

# Submission time Handle Problem Language Result Execution time Memory
1074609 2024-08-25T11:25:02 Z Nicolaikrob Rarest Insects (IOI22_insects) C++17
99.89 / 100
47 ms 1196 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int n, tc, il, rc = 0;
set<int> M, IU;

void mi(int i) {
    move_inside(i);
    M.insert(i);
}

void mo(int i) {
    move_outside(i);
    M.erase(i);
}

int pb() {
    return press_button()+rc;
}

void rm(bool t) {
    if(t) {
        for(auto x : M) {
            IU.erase(x);
            move_outside(x);
        }
        il -= M.size();
        rc += M.size()/tc;
        M.clear();
    }
    else {
        IU = M;
        il = M.size();
        for(auto x : M)
            move_outside(x);
        M.clear();
    }
}

bool tjek(int g) {
    for(auto i : IU) {
        mi(i);
        if(pb() > g) mo(i);
    }
    bool s = (int(M.size())+rc*tc == tc*g);
    rm(s);
    return s;
}

int min_cardinality(int N) {
    il = n = N; mi(0);
    for(int i = 1; i < n; i++) {
        mi(i);
        if(pb() > 1) mo(i);
    }
    tc = M.size();
    for(int i = 0; i < n; i++)
        IU.insert(i);
    rm(1);
    int l = 1, u = n/tc;
    while(l < u) {
        int g = (l+u+1)/2;
        if(tjek(g)) l = g;
        else u = g-1;
    }
    return l;
}
# 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 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 4 ms 444 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 4 ms 644 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 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 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 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 4 ms 444 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 4 ms 644 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 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 12 ms 344 KB Output is correct
24 Correct 5 ms 724 KB Output is correct
25 Correct 13 ms 344 KB Output is correct
26 Correct 10 ms 344 KB Output is correct
27 Correct 16 ms 492 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 24 ms 600 KB Output is correct
30 Correct 18 ms 436 KB Output is correct
31 Correct 16 ms 344 KB Output is correct
32 Correct 19 ms 688 KB Output is correct
33 Correct 17 ms 600 KB Output is correct
34 Correct 18 ms 600 KB Output is correct
35 Correct 13 ms 344 KB Output is correct
36 Correct 14 ms 484 KB Output is correct
37 Correct 15 ms 764 KB Output is correct
38 Correct 14 ms 600 KB Output is correct
39 Correct 17 ms 344 KB Output is correct
40 Correct 6 ms 600 KB Output is correct
41 Correct 4 ms 444 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 0 ms 344 KB Output is correct
7 Correct 46 ms 668 KB Output is correct
8 Correct 8 ms 600 KB Output is correct
9 Correct 33 ms 600 KB Output is correct
10 Correct 29 ms 344 KB Output is correct
11 Correct 27 ms 592 KB Output is correct
12 Correct 13 ms 344 KB Output is correct
13 Correct 39 ms 416 KB Output is correct
14 Correct 34 ms 772 KB Output is correct
15 Correct 23 ms 600 KB Output is correct
16 Correct 33 ms 344 KB Output is correct
17 Correct 36 ms 340 KB Output is correct
18 Correct 26 ms 440 KB Output is correct
19 Partially correct 43 ms 408 KB Output is partially correct
20 Correct 47 ms 600 KB Output is correct
21 Correct 31 ms 344 KB Output is correct
22 Correct 29 ms 344 KB Output is correct
23 Correct 32 ms 436 KB Output is correct
24 Correct 31 ms 344 KB Output is correct
25 Correct 17 ms 600 KB Output is correct
26 Correct 14 ms 344 KB Output is correct
27 Correct 28 ms 428 KB Output is correct
28 Correct 40 ms 432 KB Output is correct
29 Partially correct 32 ms 520 KB Output is partially correct
30 Partially correct 27 ms 344 KB Output is partially correct
31 Correct 34 ms 600 KB Output is correct
32 Correct 35 ms 592 KB Output is correct
33 Correct 40 ms 436 KB Output is correct
34 Correct 39 ms 684 KB Output is correct
35 Partially correct 37 ms 672 KB Output is partially correct
36 Partially correct 33 ms 676 KB Output is partially correct
37 Correct 28 ms 596 KB Output is correct
38 Correct 26 ms 344 KB Output is correct
39 Correct 31 ms 344 KB Output is correct
40 Correct 20 ms 344 KB Output is correct
41 Partially correct 40 ms 600 KB Output is partially correct
42 Partially correct 36 ms 536 KB Output is partially correct
43 Correct 7 ms 464 KB Output is correct
44 Correct 36 ms 1196 KB Output is correct
45 Correct 30 ms 428 KB Output is correct
46 Correct 10 ms 344 KB Output is correct
47 Correct 13 ms 344 KB Output is correct
48 Correct 15 ms 672 KB Output is correct