Submission #628134

# Submission time Handle Problem Language Result Execution time Memory
628134 2022-08-13T05:59:52 Z Hanksburger Rarest Insects (IOI22_insects) C++17
100 / 100
61 ms 308 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
bool a[2005], b[2005];
vector<int> v;
int min_cardinality(int n)
{
    srand(time(0));
    for (int i=0; i<n; i++)
        v.push_back(i);
    random_shuffle(v.begin(), v.end());
    int d=0;
    for (int i:v)
    {
        move_inside(i);
        b[i]=1;
        d++;
        if (press_button()>1)
        {
            move_outside(i);
            b[i]=0;
            d--;
        }
    }
    for (int i:v)
    {
        if (b[i])
        {
            move_outside(i);
            a[i]=1;
        }
    }
    int l=0, r=(n-d)/d, ans=1;
    while (l<r)
    {
        random_shuffle(v.begin(), v.end());
        int k=(l+r+1)/2, cnt=0;
        for (int i:v)
        {
            if (a[i])
                continue;
            move_inside(i);
            b[i]=1;
            cnt++;
            if (press_button()>k)
            {
                move_outside(i);
                b[i]=0;
                cnt--;
            }
            if (cnt==k*d)
                break;
        }
        if (cnt==k*d)
        {
            for (int i:v)
            {
                if (a[i])
                    continue;
                if (b[i])
                {
                    move_outside(i);
                    a[i]=1;
                }
            }
            ans+=k;
            r-=k;
        }
        else
        {
            for (int i:v)
            {
                if (a[i])
                    continue;
                if (b[i])
                {
                    move_outside(i);
                    b[i]=0;
                }
                else
                    a[i]=1;
            }
            r=k-1;
        }
    }
    return ans+l;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 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 4 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 5 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 4 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 3 ms 256 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 5 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 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 4 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 5 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 4 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 3 ms 256 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 5 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 16 ms 208 KB Output is correct
24 Correct 10 ms 208 KB Output is correct
25 Correct 16 ms 208 KB Output is correct
26 Correct 30 ms 208 KB Output is correct
27 Correct 18 ms 208 KB Output is correct
28 Correct 12 ms 208 KB Output is correct
29 Correct 27 ms 208 KB Output is correct
30 Correct 22 ms 208 KB Output is correct
31 Correct 20 ms 208 KB Output is correct
32 Correct 23 ms 208 KB Output is correct
33 Correct 23 ms 208 KB Output is correct
34 Correct 20 ms 208 KB Output is correct
35 Correct 24 ms 208 KB Output is correct
36 Correct 26 ms 208 KB Output is correct
37 Correct 39 ms 208 KB Output is correct
38 Correct 26 ms 208 KB Output is correct
39 Correct 17 ms 208 KB Output is correct
40 Correct 13 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 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 1 ms 208 KB Output is correct
7 Correct 51 ms 296 KB Output is correct
8 Correct 17 ms 208 KB Output is correct
9 Correct 33 ms 308 KB Output is correct
10 Correct 52 ms 208 KB Output is correct
11 Correct 37 ms 208 KB Output is correct
12 Correct 21 ms 296 KB Output is correct
13 Correct 42 ms 208 KB Output is correct
14 Correct 61 ms 208 KB Output is correct
15 Correct 40 ms 296 KB Output is correct
16 Correct 35 ms 208 KB Output is correct
17 Correct 35 ms 208 KB Output is correct
18 Correct 38 ms 208 KB Output is correct
19 Correct 52 ms 308 KB Output is correct
20 Correct 47 ms 300 KB Output is correct
21 Correct 51 ms 208 KB Output is correct
22 Correct 45 ms 296 KB Output is correct
23 Correct 45 ms 208 KB Output is correct
24 Correct 47 ms 208 KB Output is correct
25 Correct 39 ms 208 KB Output is correct
26 Correct 16 ms 308 KB Output is correct
27 Correct 38 ms 208 KB Output is correct
28 Correct 46 ms 208 KB Output is correct
29 Correct 49 ms 208 KB Output is correct
30 Correct 53 ms 208 KB Output is correct
31 Correct 41 ms 208 KB Output is correct
32 Correct 55 ms 208 KB Output is correct
33 Correct 45 ms 208 KB Output is correct
34 Correct 54 ms 208 KB Output is correct
35 Correct 41 ms 208 KB Output is correct
36 Correct 50 ms 208 KB Output is correct
37 Correct 54 ms 208 KB Output is correct
38 Correct 41 ms 208 KB Output is correct
39 Correct 46 ms 208 KB Output is correct
40 Correct 50 ms 208 KB Output is correct
41 Correct 54 ms 208 KB Output is correct
42 Correct 37 ms 208 KB Output is correct
43 Correct 11 ms 208 KB Output is correct
44 Correct 32 ms 208 KB Output is correct
45 Correct 36 ms 304 KB Output is correct
46 Correct 27 ms 292 KB Output is correct
47 Correct 19 ms 296 KB Output is correct
48 Correct 22 ms 208 KB Output is correct