답안 #1054616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054616 2024-08-12T11:06:41 Z shmax 드문 곤충 (IOI22_insects) C++17
25 / 100
228 ms 740 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) {
      |          ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 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 2 ms 440 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 8 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 14 ms 344 KB Output is correct
13 Correct 10 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 6 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 8 ms 344 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 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 2 ms 440 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 8 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 14 ms 344 KB Output is correct
13 Correct 10 ms 344 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 6 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 8 ms 344 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 9 ms 464 KB Output is correct
24 Correct 11 ms 600 KB Output is correct
25 Correct 6 ms 472 KB Output is correct
26 Correct 45 ms 452 KB Output is correct
27 Correct 67 ms 344 KB Output is correct
28 Correct 11 ms 600 KB Output is correct
29 Correct 98 ms 344 KB Output is correct
30 Correct 172 ms 452 KB Output is correct
31 Correct 28 ms 344 KB Output is correct
32 Correct 43 ms 472 KB Output is correct
33 Correct 46 ms 472 KB Output is correct
34 Correct 38 ms 344 KB Output is correct
35 Correct 29 ms 468 KB Output is correct
36 Correct 37 ms 468 KB Output is correct
37 Correct 31 ms 468 KB Output is correct
38 Correct 27 ms 344 KB Output is correct
39 Correct 31 ms 344 KB Output is correct
40 Correct 10 ms 344 KB Output is correct
41 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is partially correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 15 ms 496 KB Output is correct
8 Correct 15 ms 600 KB Output is correct
9 Correct 13 ms 484 KB Output is correct
10 Partially correct 139 ms 740 KB Output is partially correct
11 Partially correct 121 ms 724 KB Output is partially correct
12 Correct 18 ms 588 KB Output is correct
13 Incorrect 228 ms 584 KB Too many queries.
14 Halted 0 ms 0 KB -