Submission #726715

# Submission time Handle Problem Language Result Execution time Memory
726715 2023-04-19T09:24:48 Z TheSahib Rarest Insects (IOI22_insects) C++17
100 / 100
56 ms 412 KB
#include "insects.h"
#include <bits/stdc++.h>
 
using namespace std;
 
 
int min_cardinality(int N) {
    vector<int> types;
    vector<int> left;
    for (int i = 0; i < N; i++)
    {
        move_inside(i);
        if(press_button() > 1){
            left.push_back(i);
            move_outside(i);
        }
        else{
            types.push_back(i);
        }
    }
    int inside = types.size();
    //srand(time);
    random_shuffle(left.begin(), left.end());

    int l = 2, r = N / types.size();
    int ans = 1;
    while(l <= r){
        vector<int> tmp;
        int mid = (l + r) / 2;
        for(int a:left){
            if(inside == mid * types.size()){
                tmp.push_back(a);
                continue;
            }
            move_inside(a);
            ++inside;
            if(press_button() > mid){
                move_outside(a);
                tmp.push_back(a);
                --inside;
            }
        }
 
        if(inside == mid * types.size()){
            l = mid + 1;
            ans = mid;
            left = tmp;
        }
        else{
            r = mid - 1;
            vector<int> tmp1;
            for(int a:left){
                if(find(tmp.begin(), tmp.end(), a) == tmp.end()){
                    --inside;
                    move_outside(a);
                    tmp1.push_back(a);
                }
            }
            left = tmp1;
        }
    }
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if(inside == mid * types.size()){
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
insects.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(inside == mid * types.size()){
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 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 1 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 4 ms 208 KB Output is correct
8 Correct 5 ms 296 KB Output is correct
9 Correct 4 ms 296 KB Output is correct
10 Correct 7 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 5 ms 308 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 292 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 1 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 4 ms 208 KB Output is correct
8 Correct 5 ms 296 KB Output is correct
9 Correct 4 ms 296 KB Output is correct
10 Correct 7 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 5 ms 308 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 17 ms 208 KB Output is correct
24 Correct 10 ms 304 KB Output is correct
25 Correct 20 ms 304 KB Output is correct
26 Correct 22 ms 208 KB Output is correct
27 Correct 23 ms 296 KB Output is correct
28 Correct 7 ms 208 KB Output is correct
29 Correct 22 ms 300 KB Output is correct
30 Correct 26 ms 300 KB Output is correct
31 Correct 18 ms 208 KB Output is correct
32 Correct 18 ms 208 KB Output is correct
33 Correct 25 ms 208 KB Output is correct
34 Correct 23 ms 208 KB Output is correct
35 Correct 27 ms 208 KB Output is correct
36 Correct 20 ms 208 KB Output is correct
37 Correct 25 ms 208 KB Output is correct
38 Correct 19 ms 296 KB Output is correct
39 Correct 17 ms 208 KB Output is correct
40 Correct 12 ms 304 KB Output is correct
41 Correct 8 ms 300 KB Output is correct
# 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 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 34 ms 288 KB Output is correct
8 Correct 17 ms 308 KB Output is correct
9 Correct 46 ms 208 KB Output is correct
10 Correct 35 ms 208 KB Output is correct
11 Correct 38 ms 308 KB Output is correct
12 Correct 23 ms 308 KB Output is correct
13 Correct 48 ms 304 KB Output is correct
14 Correct 51 ms 300 KB Output is correct
15 Correct 44 ms 296 KB Output is correct
16 Correct 43 ms 292 KB Output is correct
17 Correct 34 ms 300 KB Output is correct
18 Correct 49 ms 208 KB Output is correct
19 Correct 42 ms 208 KB Output is correct
20 Correct 52 ms 208 KB Output is correct
21 Correct 24 ms 308 KB Output is correct
22 Correct 56 ms 208 KB Output is correct
23 Correct 27 ms 296 KB Output is correct
24 Correct 47 ms 304 KB Output is correct
25 Correct 28 ms 412 KB Output is correct
26 Correct 21 ms 288 KB Output is correct
27 Correct 22 ms 336 KB Output is correct
28 Correct 36 ms 300 KB Output is correct
29 Correct 41 ms 208 KB Output is correct
30 Correct 35 ms 304 KB Output is correct
31 Correct 37 ms 308 KB Output is correct
32 Correct 47 ms 328 KB Output is correct
33 Correct 52 ms 300 KB Output is correct
34 Correct 49 ms 296 KB Output is correct
35 Correct 41 ms 208 KB Output is correct
36 Correct 40 ms 336 KB Output is correct
37 Correct 43 ms 300 KB Output is correct
38 Correct 43 ms 208 KB Output is correct
39 Correct 36 ms 312 KB Output is correct
40 Correct 34 ms 208 KB Output is correct
41 Correct 45 ms 292 KB Output is correct
42 Correct 40 ms 304 KB Output is correct
43 Correct 13 ms 288 KB Output is correct
44 Correct 46 ms 304 KB Output is correct
45 Correct 37 ms 308 KB Output is correct
46 Correct 30 ms 340 KB Output is correct
47 Correct 28 ms 308 KB Output is correct
48 Correct 28 ms 304 KB Output is correct