Submission #1054754

# Submission time Handle Problem Language Result Execution time Memory
1054754 2024-08-12T11:57:14 Z Ignut Rarest Insects (IOI22_insects) C++17
0 / 100
103 ms 676 KB
/* Ignut
started: 11.08.2024
now: 12.08.2024
████████████████████████████████████████████████████████████████████
████████████████████████████████    ████████████████████████████████
██████████████████████████████        ██████████████████████████████
██████      ██████████████████        ██████████████████      ██████
██████          ██████████████        ██████████████          ██████
██████      ██    ████████████        ████████████    ██      ██████
██████      ████    ██████████        ██████████    ████      ██████
██████      ████      ██████████    ██████████      ████      ██████
██████      ████      ██████████    ██████████    ██████      ██████
██████      ██████    ██████████    ██████████    ██████      ██████
██████      ██████    ████████        ████████    ██████      ██████
██████      ██████      ██████        ██████      ██████      ██████
██████      ████        ████            ████        ████      ██████
██████            ██████████    ████    ██████████            ██████
██████      ██      ██████    ████████    ██████      ██      ██████
██████      ██████            ████████            ██████      ██████
██████                    ██            ██                    ██████
██████████████████████      ████    ████      ██████████████████████
████████████████████████      ██    ██      ████████████████████████
██████████████████████████                ██████████████████████████
██████████████████████████████        ██████████████████████████████
████████████████████████████████████████████████████████████████████
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void move_inside(int i);
void move_outside(int i);
int press_button();

int n;

vector<int> diff;

vector<int> in;

int prev_mid = 1;

int Go(int maxCount) {
    if (prev_mid < maxCount) {
        while (!in.empty()) move_outside(in.back()), in.pop_back();
    }
    prev_mid = maxCount;
    for (int i = 0; i < n; i ++) {
        move_inside(i);
        in.push_back(i);
        if (press_button() > maxCount) {
            move_outside(i);
            in.pop_back();
        }
    }
    int res = in.size();
    if (maxCount == 1) diff = in;
    return res;
}

int min_cardinality(int N) {
    n = N;
    int cntDiff = Go(1);
    
    if (cntDiff <= 0) {
        int minRes = N, sum = 0;
        for (int i = 0; i < cntDiff - 1; i ++) {
            vector<int> in;
            in.push_back(diff[i]);
            move_inside(diff[i]);
            for (int j = diff[i] + 1; j < N; j ++) {
                move_inside(j);
                in.push_back(j);
                // cout << "try " << j << ' ';
                if (press_button() != in.size()) {
                    in.pop_back();
                    move_outside(j);
                    // cout << "! ";
                }
            }
            // cout << '\n';
            minRes = min(minRes, int(in.size()));
            sum += in.size();
            // cout << "have : " << in.size() << '\n';
            // for (int val : in) cout << val << ' ';
            // cout << '\n';
            while (!in.empty()) {
                move_outside(in.back());
                in.pop_back();
            }
        }
        minRes = min(minRes, N - sum);
        return minRes;
    }

    int lo = 1, hi = N / cntDiff;
    while (lo < hi) {
        int mid = lo + (hi - lo + 1) / 2;
        if (1ll * Go(mid) == 1ll * mid * cntDiff)
            lo = mid;
        else
            hi = mid - 1;
    }
    return lo;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:77:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |                 if (press_button() != in.size()) {
      |                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 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 1 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Incorrect 3 ms 600 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 1 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Incorrect 3 ms 600 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 Partially correct 0 ms 344 KB Output is partially correct
7 Partially correct 103 ms 672 KB Output is partially correct
8 Correct 12 ms 432 KB Output is correct
9 Partially correct 72 ms 676 KB Output is partially correct
10 Partially correct 51 ms 668 KB Output is partially correct
11 Partially correct 98 ms 428 KB Output is partially correct
12 Correct 20 ms 344 KB Output is correct
13 Incorrect 93 ms 420 KB Wrong answer.
14 Halted 0 ms 0 KB -