Submission #1054639

# Submission time Handle Problem Language Result Execution time Memory
1054639 2024-08-12T11:18:39 Z shmax Rarest Insects (IOI22_insects) C++17
0 / 100
3 ms 504 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 (tr > 2) {
        int tm = tr / diff;
        if (check(tm)) {
            return tm;
        } else {
            tr = tcnt/diff;
        }
    }
    if (check(2)) {
        return 2;
    }
    return 1;
}

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) {
      |          ^~~~~~~
insects.cpp:38:9: warning: unused variable 'tl' [-Wunused-variable]
   38 |     int tl = 1;
      |         ^~
# 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 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Incorrect 2 ms 344 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 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 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Incorrect 2 ms 344 KB Wrong answer.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 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 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Wrong answer.
7 Halted 0 ms 0 KB -