Submission #1054622

# Submission time Handle Problem Language Result Execution time Memory
1054622 2024-08-12T11:08:09 Z shmax Rarest Insects (IOI22_insects) C++17
25 / 100
203 ms 856 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;
#define len(x) ((int)(x.size()))
#define all(x) x.begin(), x.end()
template<typename T>
using vec = vector<T>;

template<typename T>
using graph = vec<vec<T>>;


mt19937 rnd(2312);

int min_cardinality(int n) {
    graph<int> g(n);
    auto connect = [&](int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    };
    vec<int> ord(n);
    int diff = 0;
    vec<int> in;
    for (int i = 0; i < n; i++) {
        move_inside(i);
        if (press_button() > 1) {
            move_outside(i);
        } else {
            diff++;
            in.push_back(i);
        }
    }
    for (auto x: in) {
        move_outside(x);
    }
    int tcnt = n;
    int tl = 1;
    int tr = tcnt;
    iota(all(ord), 0);
    auto check = [&](int x) {
        int cnt = 0;
        vec<int> ins;
        for (int i: ord) {
            move_inside(i);
            if (press_button() > x) {
                move_outside(i);
            } else {
                cnt++;
                ins.push_back(i);
            }
            if (cnt == x * diff) break;
        }
        for (auto y: ins) {
            move_outside(y);
        }
        tcnt = cnt;
        return cnt == x * diff;
    };

    while (tl < tr) {
        int tm = tr / diff;
        if (check(tm)) {
            tl = tm;
            tr = tm;
        } else {
            tr = tcnt;
        }
    }
    return tl;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:18:10: warning: variable 'connect' set but not used [-Wunused-but-set-variable]
   18 |     auto connect = [&](int u, int v) {
      |          ^~~~~~~
# Verdict Execution time Memory 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 432 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 7 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 11 ms 344 KB Output is correct
13 Correct 8 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
18 Correct 5 ms 596 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory 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 432 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 7 ms 344 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 11 ms 344 KB Output is correct
13 Correct 8 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 7 ms 344 KB Output is correct
18 Correct 5 ms 596 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 6 ms 344 KB Output is correct
24 Correct 8 ms 476 KB Output is correct
25 Correct 9 ms 464 KB Output is correct
26 Correct 44 ms 728 KB Output is correct
27 Correct 38 ms 344 KB Output is correct
28 Correct 8 ms 344 KB Output is correct
29 Correct 125 ms 600 KB Output is correct
30 Correct 163 ms 704 KB Output is correct
31 Correct 38 ms 344 KB Output is correct
32 Correct 46 ms 344 KB Output is correct
33 Correct 68 ms 468 KB Output is correct
34 Correct 58 ms 460 KB Output is correct
35 Correct 26 ms 344 KB Output is correct
36 Correct 60 ms 600 KB Output is correct
37 Correct 40 ms 696 KB Output is correct
38 Correct 40 ms 344 KB Output is correct
39 Correct 24 ms 604 KB Output is correct
40 Correct 10 ms 344 KB Output is correct
41 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory 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 Partially correct 0 ms 412 KB Output is partially correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 14 ms 344 KB Output is correct
8 Correct 12 ms 496 KB Output is correct
9 Correct 19 ms 592 KB Output is correct
10 Partially correct 134 ms 856 KB Output is partially correct
11 Partially correct 112 ms 344 KB Output is partially correct
12 Correct 19 ms 344 KB Output is correct
13 Incorrect 203 ms 724 KB Too many queries.
14 Halted 0 ms 0 KB -