답안 #627673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627673 2022-08-12T18:19:18 Z emuyumi 드문 곤충 (IOI22_insects) C++17
95.9 / 100
73 ms 428 KB
#include <bits/stdc++.h>
#include "insects.h"

using namespace std;

int min_cardinality(int N){
    vector<int> out, in;
    int types = 0;
    for (int i = 0; i < N; ++i){
        move_inside(i);
        in.push_back(i);
        if (press_button() != 1){
            move_outside(i);
            in.pop_back();
            out.push_back(i);
        }
        else types++;
    }
    if (types == 1){
        return N;
    }

    for (int x : in){
        move_outside(x);
    }
    in.clear();

    int hi = (N - types) / types;
    int ans = 1;
    for (int b = __lg(hi); b >= 0; --b){
        vector<int> tmp = out;
        out.clear();
        for (int x : tmp){
            move_inside(x);
            in.push_back(x);
            if (press_button() > (1<<b)){
                move_outside(x);
                in.pop_back();
                out.push_back(x);
            }
        }
        if (in.size() == types * (1<<b)){
            ans += (1<<b);
            for (int x : in){
                move_outside(x);
            }
            in.clear();
        }
        else{
            out.clear();
            for (int x : in){
                move_outside(x);
            }
            swap(in, out);
        }
    }
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:42:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |         if (in.size() == types * (1<<b)){
      |             ~~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
6 Correct 2 ms 300 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 6 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 6 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 5 ms 208 KB Output is correct
16 Correct 7 ms 372 KB Output is correct
17 Correct 4 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 5 ms 300 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
6 Correct 2 ms 300 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 6 ms 208 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 6 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 5 ms 208 KB Output is correct
16 Correct 7 ms 372 KB Output is correct
17 Correct 4 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 5 ms 300 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 12 ms 304 KB Output is correct
24 Correct 7 ms 208 KB Output is correct
25 Correct 29 ms 296 KB Output is correct
26 Correct 15 ms 304 KB Output is correct
27 Correct 22 ms 208 KB Output is correct
28 Correct 13 ms 304 KB Output is correct
29 Correct 24 ms 208 KB Output is correct
30 Correct 25 ms 304 KB Output is correct
31 Correct 25 ms 288 KB Output is correct
32 Correct 36 ms 296 KB Output is correct
33 Correct 34 ms 300 KB Output is correct
34 Correct 31 ms 288 KB Output is correct
35 Correct 34 ms 296 KB Output is correct
36 Correct 18 ms 208 KB Output is correct
37 Correct 28 ms 296 KB Output is correct
38 Correct 27 ms 300 KB Output is correct
39 Correct 32 ms 208 KB Output is correct
40 Correct 18 ms 208 KB Output is correct
41 Correct 15 ms 308 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 21 ms 308 KB Output is correct
8 Correct 9 ms 308 KB Output is correct
9 Correct 61 ms 424 KB Output is correct
10 Partially correct 69 ms 208 KB Output is partially correct
11 Correct 49 ms 284 KB Output is correct
12 Correct 20 ms 208 KB Output is correct
13 Partially correct 64 ms 296 KB Output is partially correct
14 Partially correct 64 ms 308 KB Output is partially correct
15 Correct 48 ms 304 KB Output is correct
16 Correct 56 ms 308 KB Output is correct
17 Correct 29 ms 304 KB Output is correct
18 Correct 61 ms 308 KB Output is correct
19 Partially correct 65 ms 300 KB Output is partially correct
20 Correct 59 ms 296 KB Output is correct
21 Partially correct 28 ms 296 KB Output is partially correct
22 Partially correct 60 ms 340 KB Output is partially correct
23 Partially correct 53 ms 296 KB Output is partially correct
24 Correct 40 ms 208 KB Output is correct
25 Correct 24 ms 304 KB Output is correct
26 Correct 26 ms 296 KB Output is correct
27 Correct 35 ms 324 KB Output is correct
28 Correct 70 ms 304 KB Output is correct
29 Partially correct 44 ms 284 KB Output is partially correct
30 Partially correct 69 ms 316 KB Output is partially correct
31 Partially correct 50 ms 316 KB Output is partially correct
32 Partially correct 73 ms 428 KB Output is partially correct
33 Partially correct 29 ms 300 KB Output is partially correct
34 Partially correct 37 ms 296 KB Output is partially correct
35 Partially correct 34 ms 300 KB Output is partially correct
36 Partially correct 61 ms 300 KB Output is partially correct
37 Partially correct 31 ms 424 KB Output is partially correct
38 Partially correct 71 ms 424 KB Output is partially correct
39 Correct 34 ms 300 KB Output is correct
40 Correct 45 ms 300 KB Output is correct
41 Correct 30 ms 300 KB Output is correct
42 Correct 42 ms 312 KB Output is correct
43 Correct 18 ms 304 KB Output is correct
44 Correct 22 ms 304 KB Output is correct
45 Correct 59 ms 308 KB Output is correct
46 Correct 26 ms 300 KB Output is correct
47 Correct 18 ms 308 KB Output is correct
48 Correct 26 ms 332 KB Output is correct