답안 #1076357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076357 2024-08-26T13:16:05 Z zsombor 드문 곤충 (IOI22_insects) C++17
60.31 / 100
101 ms 1080 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int n, ans = 1e9;
vector<bool> b(2e3, false);
vector<int> v;
vector<bool> V(2e3, false);
vector<int> t(2e3, 0);
vector<int> cnt(2e3, 0);

void be(int i) {
    if (!b[i]) move_inside(i);
    b[i] = true;
}

void ki(int i) {
    if (b[i]) move_outside(i);
    b[i] = false;
}

int min_cardinality(int N) {
    n = N;
    for (int i = 0; i < n; i++) {
        be(i);
        if (press_button() == 1) {
            t[i] = v.size();
            v.push_back(i);
            V[i] = true;
        } else ki(i);
    }
    for (int j = 0; (1 << j) < v.size(); j++) {
        for (int i = 0; i < v.size(); i++) (i & (1 << j) ? be(v[i]) : ki(v[i]));
        for (int i = 0; i < n; i++) {
            if (V[i]) continue;
            be(i);
            t[i] += (press_button() - 1) * (1 << j);
            ki(i);
        }
    }
    for (int i = 0; i < n; i++) cnt[t[i]]++;
    for (int i = 0; i < v.size(); i++) ans = min(ans, cnt[i]);
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int j = 0; (1 << j) < v.size(); j++) {
      |                     ~~~~~~~~~^~~~~~~~~~
insects.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int i = 0; i < v.size(); i++) (i & (1 << j) ? be(v[i]) : ki(v[i]));
      |                         ~~^~~~~~~~~~
insects.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i < v.size(); i++) ans = min(ans, cnt[i]);
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 5 ms 344 KB Output is correct
23 Correct 6 ms 344 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 18 ms 344 KB Output is correct
26 Correct 33 ms 344 KB Output is correct
27 Correct 13 ms 344 KB Output is correct
28 Correct 23 ms 340 KB Output is correct
29 Correct 23 ms 344 KB Output is correct
30 Correct 39 ms 344 KB Output is correct
31 Correct 21 ms 344 KB Output is correct
32 Correct 22 ms 344 KB Output is correct
33 Correct 34 ms 344 KB Output is correct
34 Correct 26 ms 344 KB Output is correct
35 Correct 20 ms 344 KB Output is correct
36 Correct 29 ms 344 KB Output is correct
37 Correct 55 ms 344 KB Output is correct
38 Correct 39 ms 344 KB Output is correct
39 Correct 55 ms 344 KB Output is correct
40 Correct 47 ms 600 KB Output is correct
41 Correct 27 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 388 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 15 ms 344 KB Output is correct
8 Partially correct 10 ms 344 KB Output is partially correct
9 Partially correct 54 ms 344 KB Output is partially correct
10 Partially correct 85 ms 344 KB Output is partially correct
11 Correct 31 ms 344 KB Output is correct
12 Partially correct 94 ms 1080 KB Output is partially correct
13 Partially correct 49 ms 344 KB Output is partially correct
14 Partially correct 74 ms 344 KB Output is partially correct
15 Partially correct 52 ms 344 KB Output is partially correct
16 Partially correct 29 ms 344 KB Output is partially correct
17 Partially correct 64 ms 344 KB Output is partially correct
18 Partially correct 56 ms 344 KB Output is partially correct
19 Partially correct 64 ms 344 KB Output is partially correct
20 Partially correct 91 ms 344 KB Output is partially correct
21 Partially correct 85 ms 344 KB Output is partially correct
22 Partially correct 93 ms 344 KB Output is partially correct
23 Partially correct 100 ms 344 KB Output is partially correct
24 Partially correct 92 ms 344 KB Output is partially correct
25 Partially correct 86 ms 688 KB Output is partially correct
26 Partially correct 62 ms 436 KB Output is partially correct
27 Partially correct 94 ms 344 KB Output is partially correct
28 Partially correct 93 ms 344 KB Output is partially correct
29 Partially correct 77 ms 344 KB Output is partially correct
30 Partially correct 68 ms 344 KB Output is partially correct
31 Partially correct 80 ms 344 KB Output is partially correct
32 Partially correct 85 ms 344 KB Output is partially correct
33 Partially correct 85 ms 344 KB Output is partially correct
34 Partially correct 101 ms 344 KB Output is partially correct
35 Partially correct 82 ms 344 KB Output is partially correct
36 Partially correct 96 ms 344 KB Output is partially correct
37 Partially correct 75 ms 344 KB Output is partially correct
38 Partially correct 83 ms 344 KB Output is partially correct
39 Partially correct 101 ms 344 KB Output is partially correct
40 Partially correct 99 ms 344 KB Output is partially correct
41 Partially correct 96 ms 340 KB Output is partially correct
42 Partially correct 83 ms 344 KB Output is partially correct
43 Partially correct 9 ms 344 KB Output is partially correct
44 Partially correct 39 ms 344 KB Output is partially correct
45 Correct 20 ms 344 KB Output is correct
46 Partially correct 94 ms 688 KB Output is partially correct
47 Partially correct 61 ms 436 KB Output is partially correct
48 Partially correct 84 ms 676 KB Output is partially correct