답안 #825880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825880 2023-08-15T09:02:21 Z PixelCat 드문 곤충 (IOI22_insects) C++17
47.5 / 100
209 ms 520 KB
#include "insects.h"

#ifdef NYAOWO
#include "stub.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;

int find_types(int n) {
    vector<int> rep;
    For(i, 0, n - 1) {
        move_inside(i);
        if(press_button() == 1) {
            rep.eb(i);
        } else {
            move_outside(i);
        }
    }
    for(auto &i:rep) move_outside(i);
    return sz(rep);
}

// # of all types >= k ?
bool check(int k, int n, int m) {
    vector<int> owo;
    For(i, 0, n - 1) {
        move_inside(i);
        // cerr << press_button() << " \n"[i == n - 1];
        if(press_button() <= k) {
            owo.eb(i);
        } else {
            move_outside(i);
        }
    }
    for(auto &i:owo) move_outside(i);
    // cerr << k << " " << sz(owo) << "\n";
    return m * k == sz(owo);
}

int min_cardinality(int n) {
    int m = find_types(n);
    cerr << m << "\n";
    int hi = n + 1, lo = 0;
    while(hi - lo > 1) {
        int mi = (hi + lo) / 2;
        if(check(mi, n, m)) lo = mi;
        else hi = mi;
    }
    return lo;
}

/*

6
5 8 9 5 9 9

1
7

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 228 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 20 ms 300 KB Output is correct
7 Correct 9 ms 300 KB Output is correct
8 Correct 12 ms 296 KB Output is correct
9 Correct 13 ms 300 KB Output is correct
10 Correct 17 ms 208 KB Output is correct
11 Correct 10 ms 304 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 14 ms 300 KB Output is correct
14 Correct 19 ms 300 KB Output is correct
15 Correct 8 ms 304 KB Output is correct
16 Correct 11 ms 300 KB Output is correct
17 Correct 18 ms 300 KB Output is correct
18 Correct 7 ms 304 KB Output is correct
19 Correct 11 ms 208 KB Output is correct
20 Correct 15 ms 308 KB Output is correct
21 Correct 15 ms 208 KB Output is correct
22 Correct 19 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 228 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 20 ms 300 KB Output is correct
7 Correct 9 ms 300 KB Output is correct
8 Correct 12 ms 296 KB Output is correct
9 Correct 13 ms 300 KB Output is correct
10 Correct 17 ms 208 KB Output is correct
11 Correct 10 ms 304 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 14 ms 300 KB Output is correct
14 Correct 19 ms 300 KB Output is correct
15 Correct 8 ms 304 KB Output is correct
16 Correct 11 ms 300 KB Output is correct
17 Correct 18 ms 300 KB Output is correct
18 Correct 7 ms 304 KB Output is correct
19 Correct 11 ms 208 KB Output is correct
20 Correct 15 ms 308 KB Output is correct
21 Correct 15 ms 208 KB Output is correct
22 Correct 19 ms 208 KB Output is correct
23 Correct 74 ms 296 KB Output is correct
24 Correct 111 ms 304 KB Output is correct
25 Correct 70 ms 300 KB Output is correct
26 Correct 64 ms 296 KB Output is correct
27 Correct 59 ms 300 KB Output is correct
28 Correct 70 ms 208 KB Output is correct
29 Correct 57 ms 208 KB Output is correct
30 Correct 59 ms 208 KB Output is correct
31 Correct 63 ms 208 KB Output is correct
32 Correct 73 ms 300 KB Output is correct
33 Correct 75 ms 208 KB Output is correct
34 Correct 64 ms 300 KB Output is correct
35 Correct 87 ms 208 KB Output is correct
36 Correct 93 ms 208 KB Output is correct
37 Correct 62 ms 296 KB Output is correct
38 Correct 83 ms 284 KB Output is correct
39 Correct 56 ms 304 KB Output is correct
40 Correct 69 ms 296 KB Output is correct
41 Correct 69 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Partially correct 1 ms 208 KB Output is partially correct
6 Partially correct 1 ms 208 KB Output is partially correct
7 Partially correct 133 ms 424 KB Output is partially correct
8 Partially correct 192 ms 304 KB Output is partially correct
9 Partially correct 183 ms 300 KB Output is partially correct
10 Partially correct 189 ms 300 KB Output is partially correct
11 Partially correct 209 ms 208 KB Output is partially correct
12 Partially correct 150 ms 308 KB Output is partially correct
13 Partially correct 144 ms 296 KB Output is partially correct
14 Partially correct 113 ms 296 KB Output is partially correct
15 Partially correct 161 ms 296 KB Output is partially correct
16 Partially correct 175 ms 376 KB Output is partially correct
17 Partially correct 169 ms 304 KB Output is partially correct
18 Partially correct 157 ms 300 KB Output is partially correct
19 Partially correct 140 ms 424 KB Output is partially correct
20 Partially correct 171 ms 304 KB Output is partially correct
21 Partially correct 182 ms 396 KB Output is partially correct
22 Partially correct 164 ms 296 KB Output is partially correct
23 Partially correct 207 ms 304 KB Output is partially correct
24 Partially correct 201 ms 376 KB Output is partially correct
25 Partially correct 182 ms 300 KB Output is partially correct
26 Partially correct 167 ms 308 KB Output is partially correct
27 Partially correct 209 ms 308 KB Output is partially correct
28 Partially correct 130 ms 292 KB Output is partially correct
29 Partially correct 209 ms 304 KB Output is partially correct
30 Partially correct 137 ms 300 KB Output is partially correct
31 Partially correct 102 ms 520 KB Output is partially correct
32 Partially correct 125 ms 304 KB Output is partially correct
33 Partially correct 146 ms 476 KB Output is partially correct
34 Partially correct 143 ms 300 KB Output is partially correct
35 Partially correct 150 ms 300 KB Output is partially correct
36 Partially correct 160 ms 296 KB Output is partially correct
37 Partially correct 134 ms 300 KB Output is partially correct
38 Partially correct 157 ms 340 KB Output is partially correct
39 Partially correct 184 ms 304 KB Output is partially correct
40 Partially correct 159 ms 368 KB Output is partially correct
41 Partially correct 153 ms 304 KB Output is partially correct
42 Partially correct 126 ms 332 KB Output is partially correct
43 Partially correct 29 ms 208 KB Output is partially correct
44 Partially correct 130 ms 304 KB Output is partially correct
45 Partially correct 189 ms 300 KB Output is partially correct
46 Partially correct 180 ms 380 KB Output is partially correct
47 Partially correct 137 ms 300 KB Output is partially correct
48 Partially correct 159 ms 312 KB Output is partially correct