답안 #825992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825992 2023-08-15T09:45:23 Z PixelCat 드문 곤충 (IOI22_insects) C++17
87.5 / 100
78 ms 444 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(vector<int> &sus) {
    vector<int> rep;
    vector<int> uwu;
    for(auto &i:sus) {
        move_inside(i);
        if(press_button() == 1) {
            rep.eb(i);
        } else {
            move_outside(i);
            uwu.eb(i);
        }
    }
    sus = uwu;
    // for(auto &i:rep) move_outside(i);
    return sz(rep);
}

// # of all types >= k ?
bool check(int k, int m, vector<int> &sus, int good) {
    if(sz(sus) < k * m) return false;
    // for(auto &i:sus) cerr << i << " ";
    vector<int> owo;
    vector<int> uwu;
    for(auto &i:sus) {
        move_inside(i);
        if(press_button() > k + good) {
            uwu.eb(i);
            move_outside(i);
        } else {
            owo.eb(i);
        }
    }
    // cerr << " - " << k << " " << sz(owo) + good << " " << (m * k == sz(owo) + good) << "\n";
    if(m * k == sz(owo)) {
        sus = uwu;
        return true;
    }
    sus = owo;
    for(auto &i:owo) move_outside(i);
    return false;
}

int min_cardinality(int n) {

    vector<int> sus;
    For(i, 0, n - 1) sus.eb(i);
    random_shuffle(all(sus));

    int m = find_types(sus);
    cerr << m << "\n";

    int hi = n / m + 1, lo = 1;
    while(hi - lo > 1) {
        int mi = max(1, int(sqrt(hi * lo)) - lo);
        if(check(mi, m, sus, lo)) lo += mi;
        else hi = lo + 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 0 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 9 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 6 ms 304 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 3 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 3 ms 208 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 6 ms 300 KB Output is correct
17 Correct 3 ms 304 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 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 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 9 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 6 ms 304 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 3 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 3 ms 208 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 6 ms 300 KB Output is correct
17 Correct 3 ms 304 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 3 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 38 ms 308 KB Output is correct
24 Correct 9 ms 208 KB Output is correct
25 Correct 36 ms 312 KB Output is correct
26 Correct 33 ms 336 KB Output is correct
27 Correct 14 ms 320 KB Output is correct
28 Correct 9 ms 208 KB Output is correct
29 Correct 13 ms 316 KB Output is correct
30 Correct 14 ms 316 KB Output is correct
31 Correct 35 ms 308 KB Output is correct
32 Correct 41 ms 316 KB Output is correct
33 Correct 30 ms 328 KB Output is correct
34 Correct 16 ms 304 KB Output is correct
35 Correct 28 ms 312 KB Output is correct
36 Correct 36 ms 208 KB Output is correct
37 Correct 29 ms 208 KB Output is correct
38 Correct 23 ms 312 KB Output is correct
39 Correct 14 ms 208 KB Output is correct
40 Correct 13 ms 336 KB Output is correct
41 Correct 8 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 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 300 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Partially correct 77 ms 208 KB Output is partially correct
8 Correct 14 ms 208 KB Output is correct
9 Partially correct 44 ms 316 KB Output is partially correct
10 Partially correct 59 ms 316 KB Output is partially correct
11 Correct 33 ms 316 KB Output is correct
12 Correct 20 ms 320 KB Output is correct
13 Correct 33 ms 312 KB Output is correct
14 Correct 19 ms 440 KB Output is correct
15 Partially correct 49 ms 208 KB Output is partially correct
16 Partially correct 56 ms 316 KB Output is partially correct
17 Partially correct 77 ms 320 KB Output is partially correct
18 Partially correct 42 ms 336 KB Output is partially correct
19 Partially correct 63 ms 208 KB Output is partially correct
20 Partially correct 71 ms 308 KB Output is partially correct
21 Partially correct 42 ms 320 KB Output is partially correct
22 Partially correct 51 ms 312 KB Output is partially correct
23 Correct 29 ms 316 KB Output is correct
24 Correct 22 ms 316 KB Output is correct
25 Correct 23 ms 208 KB Output is correct
26 Correct 16 ms 316 KB Output is correct
27 Partially correct 58 ms 308 KB Output is partially correct
28 Partially correct 53 ms 208 KB Output is partially correct
29 Partially correct 51 ms 308 KB Output is partially correct
30 Partially correct 49 ms 308 KB Output is partially correct
31 Partially correct 53 ms 312 KB Output is partially correct
32 Partially correct 49 ms 316 KB Output is partially correct
33 Correct 27 ms 208 KB Output is correct
34 Correct 21 ms 444 KB Output is correct
35 Partially correct 38 ms 320 KB Output is partially correct
36 Partially correct 63 ms 312 KB Output is partially correct
37 Partially correct 55 ms 320 KB Output is partially correct
38 Partially correct 53 ms 208 KB Output is partially correct
39 Partially correct 62 ms 324 KB Output is partially correct
40 Partially correct 67 ms 208 KB Output is partially correct
41 Partially correct 55 ms 316 KB Output is partially correct
42 Partially correct 64 ms 320 KB Output is partially correct
43 Correct 6 ms 208 KB Output is correct
44 Correct 26 ms 208 KB Output is correct
45 Partially correct 78 ms 308 KB Output is partially correct
46 Correct 24 ms 308 KB Output is correct
47 Correct 27 ms 316 KB Output is correct
48 Correct 28 ms 308 KB Output is correct