답안 #797746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797746 2023-07-29T20:39:42 Z HaroldVemeno 드문 곤충 (IOI22_insects) C++17
99.78 / 100
54 ms 296 KB
#include "insects.h"
#include <bits/stdc++.h>

#ifdef GUDEB
    #define D(x) cerr << #x << ": " << (x) << '\n';
    #define ifdeb if(true)
#else
    #define D(x) ;
    #define ifdeb if(false)
#endif

#define all(x) begin(x), end(x)

using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;

int min_cardinality(int n) {
    vector<bool> skip(n);
    vector<bool> box(n);
    int s = 0;
    for(int i = 0; i < n; ++i) {
        box[i] = true;
        move_inside(i);
        ++s;
        int c = press_button();
        if(c > 1) {
            move_outside(i);
            --s;
            box[i] = false;
        }
    }
    D(s)
    if(s == n) return 1;
    for(int i = 0; i < n; ++i) {
        if(box[i]) {
            move_outside(i);
            skip[i] = true;
        }
    }
    int rm = 1;
    int f = 1;
    int t = n/s;
    while(f != t) {
        int m = (f+t+1)/2;
        D(f)
        D(t)
        D(m)
        int ss = 0;
        for(int i = 0; i < n; ++i) {
            if(skip[i]) continue;
            box[i] = true;
            ++ss;
            move_inside(i);
            int c = press_button();
            if(c > m-rm) {
                move_outside(i);
                box[i] = false;
                --ss;
            }
        }
        D(ss)
        if(ss == s*(m-rm)) {
            rm = m;
            f = m;
            for(int i = 0; i < n; ++i) {
                if(box[i]) skip[i] = true;
            }
        } else {
            t = m-1;
            for(int i = 0; i < n; ++i) {
                if(!box[i]) skip[i] = true;
            }
        }
        for(int i = 0; i < n; ++i) {
            if(box[i]) move_outside(i);
            box[i] = false;
        }
    }
    return f;
}
# 결과 실행 시간 메모리 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 6 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 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 3 ms 208 KB Output is correct
13 Correct 5 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 3 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 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 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 6 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 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 3 ms 208 KB Output is correct
13 Correct 5 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 3 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 25 ms 208 KB Output is correct
24 Correct 8 ms 208 KB Output is correct
25 Correct 24 ms 208 KB Output is correct
26 Correct 24 ms 208 KB Output is correct
27 Correct 16 ms 208 KB Output is correct
28 Correct 8 ms 208 KB Output is correct
29 Correct 24 ms 208 KB Output is correct
30 Correct 13 ms 208 KB Output is correct
31 Correct 27 ms 208 KB Output is correct
32 Correct 16 ms 208 KB Output is correct
33 Correct 15 ms 208 KB Output is correct
34 Correct 27 ms 208 KB Output is correct
35 Correct 22 ms 208 KB Output is correct
36 Correct 20 ms 208 KB Output is correct
37 Correct 27 ms 208 KB Output is correct
38 Correct 21 ms 208 KB Output is correct
39 Correct 18 ms 208 KB Output is correct
40 Correct 12 ms 208 KB Output is correct
41 Correct 9 ms 208 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 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 46 ms 208 KB Output is correct
8 Correct 13 ms 208 KB Output is correct
9 Correct 23 ms 276 KB Output is correct
10 Correct 39 ms 208 KB Output is correct
11 Correct 42 ms 208 KB Output is correct
12 Correct 28 ms 208 KB Output is correct
13 Correct 49 ms 208 KB Output is correct
14 Correct 39 ms 208 KB Output is correct
15 Correct 49 ms 276 KB Output is correct
16 Correct 54 ms 208 KB Output is correct
17 Correct 42 ms 208 KB Output is correct
18 Correct 42 ms 208 KB Output is correct
19 Partially correct 40 ms 208 KB Output is partially correct
20 Correct 38 ms 208 KB Output is correct
21 Correct 21 ms 208 KB Output is correct
22 Correct 48 ms 280 KB Output is correct
23 Correct 24 ms 292 KB Output is correct
24 Correct 30 ms 208 KB Output is correct
25 Correct 27 ms 280 KB Output is correct
26 Correct 10 ms 208 KB Output is correct
27 Correct 40 ms 276 KB Output is correct
28 Correct 47 ms 208 KB Output is correct
29 Partially correct 33 ms 208 KB Output is partially correct
30 Partially correct 41 ms 208 KB Output is partially correct
31 Correct 40 ms 208 KB Output is correct
32 Correct 49 ms 208 KB Output is correct
33 Correct 35 ms 208 KB Output is correct
34 Correct 33 ms 284 KB Output is correct
35 Partially correct 37 ms 208 KB Output is partially correct
36 Partially correct 39 ms 276 KB Output is partially correct
37 Correct 42 ms 208 KB Output is correct
38 Correct 37 ms 296 KB Output is correct
39 Correct 36 ms 276 KB Output is correct
40 Correct 32 ms 284 KB Output is correct
41 Partially correct 47 ms 208 KB Output is partially correct
42 Partially correct 45 ms 208 KB Output is partially correct
43 Correct 9 ms 208 KB Output is correct
44 Correct 27 ms 208 KB Output is correct
45 Correct 39 ms 280 KB Output is correct
46 Correct 20 ms 280 KB Output is correct
47 Correct 26 ms 276 KB Output is correct
48 Correct 19 ms 280 KB Output is correct