답안 #1062165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062165 2024-08-16T20:24:39 Z jerzyk 드문 곤충 (IOI22_insects) C++17
57.01 / 100
100 ms 2904 KB
#include <bits/stdc++.h>
#include "insects.h"

using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 1000 * 1000 + 7;
bool out[N], czy[N], wh[N];
vector<int> cur;
int lft, dif;

int findDif(int n)
{
    for(int i = 0; i < n; ++i)
    {
        move_inside(i);
        cur.pb(i);
        if(press_button() > 1)
        {
            cur.pop_back();
            move_outside(i);
        }
    }
    int ans = cur.size();
    for(int i = 0; i < (int)cur.size(); ++i)
    {
        out[cur[i]] = true;
        move_outside(cur[i]);
    }
    cur.clear();
    return ans;
}

int Check(int x, int n)
{
    int ans = 0, xd = 0;
    for(int i = 0; i < n; ++i)
    {
        wh[i] = false;
        if(out[i]) continue;
        move_inside(i);
        czy[i] = true;
        ans = press_button();
        ++xd;
        if(ans > x + 1)
        {
            --xd;
            --ans;
            wh[i] = true;
            czy[i] = false;
            move_outside(i);
        }
        if(xd == dif * (x + 1))
            break;
    }
    //cerr << "xddd " << x << " " << " " << xd << " " << ans << " " << lft << "\n";
    if(xd == dif * (x + 1))
        ans = x + 1;
    else
        ans = min(ans, x);
    for(int i = 0; i < n; ++i)
    {
        if(out[i]) continue;
        if(czy[i])
            move_outside(i);
        czy[i] = false;
    }
    if(ans == x + 1)
        return ans;

    for(int i = 0; i < n; ++i)
        if(wh[i])
        {
            --lft;
            out[i] = true;
        }
    return ans;
}

int BS(int maks, int n)
{
    int p = 0, k = maks;
    while(p < k)
    {
        int s = (p + k) / 2;
        if(dif == 1)
            return lft;
        int x = Check(s, n);
        if(x > s)
            p = s + 1;
        else
            k = s;
        k = min(k, lft);
    }
    return p;
}

int min_cardinality(int n)
{
    dif = findDif(n);
    lft = n - dif;
    //cerr << "dif " << dif << "\n";
    int m = lft / dif;
    int ans = BS(m, n);
    return ans + 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 3 ms 2392 KB Output is correct
9 Correct 3 ms 2496 KB Output is correct
10 Correct 3 ms 2648 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 4 ms 2392 KB Output is correct
13 Correct 3 ms 2392 KB Output is correct
14 Correct 5 ms 2392 KB Output is correct
15 Correct 4 ms 2392 KB Output is correct
16 Correct 4 ms 2392 KB Output is correct
17 Correct 4 ms 2648 KB Output is correct
18 Correct 3 ms 2492 KB Output is correct
19 Correct 3 ms 2392 KB Output is correct
20 Correct 2 ms 2392 KB Output is correct
21 Correct 2 ms 2392 KB Output is correct
22 Correct 2 ms 2500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 3 ms 2392 KB Output is correct
9 Correct 3 ms 2496 KB Output is correct
10 Correct 3 ms 2648 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 4 ms 2392 KB Output is correct
13 Correct 3 ms 2392 KB Output is correct
14 Correct 5 ms 2392 KB Output is correct
15 Correct 4 ms 2392 KB Output is correct
16 Correct 4 ms 2392 KB Output is correct
17 Correct 4 ms 2648 KB Output is correct
18 Correct 3 ms 2492 KB Output is correct
19 Correct 3 ms 2392 KB Output is correct
20 Correct 2 ms 2392 KB Output is correct
21 Correct 2 ms 2392 KB Output is correct
22 Correct 2 ms 2500 KB Output is correct
23 Correct 5 ms 2392 KB Output is correct
24 Correct 4 ms 2392 KB Output is correct
25 Correct 29 ms 2392 KB Output is correct
26 Correct 21 ms 2904 KB Output is correct
27 Correct 17 ms 2648 KB Output is correct
28 Correct 11 ms 2648 KB Output is correct
29 Correct 16 ms 2648 KB Output is correct
30 Correct 15 ms 2600 KB Output is correct
31 Correct 53 ms 2500 KB Output is correct
32 Correct 30 ms 2392 KB Output is correct
33 Correct 40 ms 2648 KB Output is correct
34 Correct 35 ms 2392 KB Output is correct
35 Correct 41 ms 2392 KB Output is correct
36 Correct 26 ms 2648 KB Output is correct
37 Correct 28 ms 2496 KB Output is correct
38 Correct 11 ms 2392 KB Output is correct
39 Correct 18 ms 2392 KB Output is correct
40 Correct 7 ms 2392 KB Output is correct
41 Correct 7 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 7 ms 2640 KB Output is correct
8 Correct 10 ms 2640 KB Output is correct
9 Partially correct 76 ms 2480 KB Output is partially correct
10 Partially correct 54 ms 2468 KB Output is partially correct
11 Correct 33 ms 2384 KB Output is correct
12 Correct 21 ms 2496 KB Output is correct
13 Correct 35 ms 2236 KB Output is correct
14 Correct 34 ms 2392 KB Output is correct
15 Partially correct 100 ms 2864 KB Output is partially correct
16 Partially correct 94 ms 2716 KB Output is partially correct
17 Partially correct 83 ms 2724 KB Output is partially correct
18 Partially correct 87 ms 2732 KB Output is partially correct
19 Partially correct 77 ms 2624 KB Output is partially correct
20 Partially correct 82 ms 2476 KB Output is partially correct
21 Partially correct 62 ms 2640 KB Output is partially correct
22 Partially correct 52 ms 2384 KB Output is partially correct
23 Correct 39 ms 2648 KB Output is correct
24 Correct 23 ms 2232 KB Output is correct
25 Correct 17 ms 2384 KB Output is correct
26 Correct 11 ms 2384 KB Output is correct
27 Partially correct 80 ms 2496 KB Output is partially correct
28 Partially correct 54 ms 2384 KB Output is partially correct
29 Partially correct 69 ms 2896 KB Output is partially correct
30 Partially correct 78 ms 2392 KB Output is partially correct
31 Partially correct 44 ms 2492 KB Output is partially correct
32 Partially correct 44 ms 2724 KB Output is partially correct
33 Partially correct 24 ms 2644 KB Output is partially correct
34 Correct 35 ms 2384 KB Output is correct
35 Partially correct 80 ms 2624 KB Output is partially correct
36 Partially correct 60 ms 2724 KB Output is partially correct
37 Partially correct 52 ms 2744 KB Output is partially correct
38 Partially correct 54 ms 2716 KB Output is partially correct
39 Partially correct 48 ms 2884 KB Output is partially correct
40 Partially correct 36 ms 2392 KB Output is partially correct
41 Partially correct 64 ms 2640 KB Output is partially correct
42 Partially correct 86 ms 2640 KB Output is partially correct
43 Correct 6 ms 2392 KB Output is correct
44 Correct 25 ms 2496 KB Output is correct
45 Partially correct 95 ms 2856 KB Output is partially correct
46 Correct 13 ms 2752 KB Output is correct
47 Correct 16 ms 2480 KB Output is correct
48 Correct 13 ms 2392 KB Output is correct