Submission #629368

# Submission time Handle Problem Language Result Execution time Memory
629368 2022-08-14T12:31:20 Z dacin21 Rarest Insects (IOI22_insects) C++17
100 / 100
67 ms 464 KB
#include "insects.h"

/*
void move_inside(int i);
void move_outside(int i);
int press_button();
*/
#include <bits/stdc++.h>
using namespace std;


vector<int> in, out;


void one_pass(vector<int> pool, int tr){
    in.clear();
    out.clear();
    for(auto &e : pool){
        move_inside(e);
        if(press_button() > tr){
            move_outside(e);
            out.push_back(e);
        } else {
            in.push_back(e);
        }
    }
    for(auto &e : in){
        move_outside(e);
    }
}

int min_cardinality(int n) {
    vector<int> all(n);
    iota(all.begin(), all.end(), 0);
    one_pass(all, 1);

    const int B = in.size();
    int ans = 1;
    all = out;
    while(all.size() >= B){
        const int l = 0, r = all.size()/B;
        // const int t = (all.size() / B + 1) / 2;
        const int t = (l+r+1+(2*(all.size()%B) >= B))/2;
        one_pass(all, t);
        if(in.size() == t*B){
            ans += t;
            all = out;
        } else {
            all = in;
        }
    }
    return ans;

}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   40 |     while(all.size() >= B){
      |           ~~~~~~~~~~~^~~~
insects.cpp:43:48: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   43 |         const int t = (l+r+1+(2*(all.size()%B) >= B))/2;
      |                               ~~~~~~~~~~~~~~~~~^~~~
insects.cpp:45:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if(in.size() == t*B){
      |            ~~~~~~~~~~^~~~~~
# 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 0 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 7 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 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 5 ms 208 KB Output is correct
14 Correct 5 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 7 ms 208 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 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 0 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 7 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 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 5 ms 208 KB Output is correct
14 Correct 5 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 7 ms 208 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 208 KB Output is correct
23 Correct 16 ms 308 KB Output is correct
24 Correct 9 ms 208 KB Output is correct
25 Correct 17 ms 208 KB Output is correct
26 Correct 18 ms 208 KB Output is correct
27 Correct 21 ms 208 KB Output is correct
28 Correct 9 ms 208 KB Output is correct
29 Correct 26 ms 308 KB Output is correct
30 Correct 26 ms 208 KB Output is correct
31 Correct 13 ms 336 KB Output is correct
32 Correct 30 ms 336 KB Output is correct
33 Correct 28 ms 312 KB Output is correct
34 Correct 27 ms 300 KB Output is correct
35 Correct 28 ms 208 KB Output is correct
36 Correct 22 ms 208 KB Output is correct
37 Correct 21 ms 464 KB Output is correct
38 Correct 28 ms 208 KB Output is correct
39 Correct 18 ms 208 KB Output is correct
40 Correct 17 ms 208 KB Output is correct
41 Correct 8 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 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 1 ms 208 KB Output is correct
7 Correct 65 ms 320 KB Output is correct
8 Correct 16 ms 316 KB Output is correct
9 Correct 58 ms 312 KB Output is correct
10 Correct 44 ms 208 KB Output is correct
11 Correct 26 ms 328 KB Output is correct
12 Correct 28 ms 316 KB Output is correct
13 Correct 42 ms 208 KB Output is correct
14 Correct 42 ms 208 KB Output is correct
15 Correct 56 ms 320 KB Output is correct
16 Correct 53 ms 328 KB Output is correct
17 Correct 33 ms 308 KB Output is correct
18 Correct 51 ms 312 KB Output is correct
19 Correct 42 ms 324 KB Output is correct
20 Correct 51 ms 312 KB Output is correct
21 Correct 64 ms 304 KB Output is correct
22 Correct 58 ms 208 KB Output is correct
23 Correct 50 ms 320 KB Output is correct
24 Correct 19 ms 320 KB Output is correct
25 Correct 24 ms 316 KB Output is correct
26 Correct 16 ms 320 KB Output is correct
27 Correct 48 ms 320 KB Output is correct
28 Correct 47 ms 320 KB Output is correct
29 Correct 67 ms 316 KB Output is correct
30 Correct 53 ms 320 KB Output is correct
31 Correct 48 ms 208 KB Output is correct
32 Correct 54 ms 316 KB Output is correct
33 Correct 47 ms 316 KB Output is correct
34 Correct 41 ms 320 KB Output is correct
35 Correct 51 ms 324 KB Output is correct
36 Correct 53 ms 208 KB Output is correct
37 Correct 54 ms 320 KB Output is correct
38 Correct 53 ms 316 KB Output is correct
39 Correct 45 ms 208 KB Output is correct
40 Correct 44 ms 308 KB Output is correct
41 Correct 48 ms 316 KB Output is correct
42 Correct 47 ms 300 KB Output is correct
43 Correct 11 ms 312 KB Output is correct
44 Correct 29 ms 312 KB Output is correct
45 Correct 51 ms 320 KB Output is correct
46 Correct 31 ms 336 KB Output is correct
47 Correct 32 ms 304 KB Output is correct
48 Correct 25 ms 304 KB Output is correct