Submission #830506

# Submission time Handle Problem Language Result Execution time Memory
830506 2023-08-19T07:24:17 Z tolbi Rarest Insects (IOI22_insects) C++17
10 / 100
230 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
#include "insects.h"
int min_cardinality(int n) {
    vector<int> par(n);
    function<int(int)> find = [&](int node)->int{
        if (par[node]==node) return node;
        return par[node]=find(par[node]);
    };
    vector<int> sz(n,1);
    iota(par.begin(), par.end(), 0);
    vector<int> crr;
    function<int()> findx;
    findx = [&]()->int{
        for (int i = 0; i < crr.size(); i++){
            move_outside(crr[i]);
            if (press_button()==1){
                for (int j=0;j<=i;j++){
                    move_inside(crr[j]);
                }
                return i;
            }
        }
        return 23;
    };
    for (int i = 0; i < n; i++){
        move_inside(i);
        if (press_button()>1){
            int pos = crr[findx()];
            sz[find(pos)]+=sz[find(i)];
            sz[find(i)]=0;
            par[i]=find(pos);
            move_outside(i);
        }
        else crr.push_back(i);
    }
    int ans = n;
    for (int i = 0; i < n; i++){
        if (find(i)!=i) continue;
        ans=min(ans,sz[i]);
    }
    return ans;
}

Compilation message

insects.cpp: In lambda function:
insects.cpp:15:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (int i = 0; i < crr.size(); i++){
      |                         ~~^~~~~~~~~~~~
# 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 0 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 4 ms 296 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 13 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 9 ms 208 KB Output is correct
16 Correct 9 ms 208 KB Output is correct
17 Correct 13 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 14 ms 208 KB Output is correct
20 Correct 25 ms 300 KB Output is correct
21 Correct 29 ms 208 KB Output is correct
22 Correct 30 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 0 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 4 ms 296 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 13 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 9 ms 208 KB Output is correct
16 Correct 9 ms 208 KB Output is correct
17 Correct 13 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 14 ms 208 KB Output is correct
20 Correct 25 ms 300 KB Output is correct
21 Correct 29 ms 208 KB Output is correct
22 Correct 30 ms 208 KB Output is correct
23 Correct 7 ms 208 KB Output is correct
24 Correct 7 ms 208 KB Output is correct
25 Correct 137 ms 208 KB Output is correct
26 Correct 93 ms 208 KB Output is correct
27 Correct 18 ms 256 KB Output is correct
28 Correct 10 ms 208 KB Output is correct
29 Correct 20 ms 208 KB Output is correct
30 Correct 64 ms 208 KB Output is correct
31 Correct 34 ms 208 KB Output is correct
32 Correct 39 ms 208 KB Output is correct
33 Correct 42 ms 208 KB Output is correct
34 Correct 55 ms 208 KB Output is correct
35 Correct 54 ms 208 KB Output is correct
36 Correct 74 ms 208 KB Output is correct
37 Correct 143 ms 208 KB Output is correct
38 Incorrect 230 ms 208 KB Too many queries.
39 Halted 0 ms 0 KB -
# 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 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 0 ms 208 KB Output is correct
7 Correct 19 ms 208 KB Output is correct
8 Correct 17 ms 320 KB Output is correct
9 Incorrect 145 ms 208 KB Too many queries.
10 Halted 0 ms 0 KB -