Submission #859220

# Submission time Handle Problem Language Result Execution time Memory
859220 2023-10-10T01:54:46 Z thinknoexit Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
int in[2020];
int min_cardinality(int n) {
    int type = 0;
    for (int i = 0;i < n;i++) {
        move_inside(i);
        if (press_button() == 2) {
            move_outside(i);
        }
        else in[i] = 1, type++;
    }
    for (int i = 0;i < n;i++) {
        if (!in[i]) move_inside(i), in[i] = 2;
    }
    int mxtype = press_button();
    for (int i = 0;i < n;i++) if (in[i] == 2) move_outside(i);
    if (type == 1) return n;
    if (type == n) return 1;
    int mxans = n / type;
    int l = 1, r = min(n - mxtype, mxans);
    while (l < r) {
        int mid = (l + r + 1) / 2;
        int sz = mid - l;
        int cnt = 0;
        for (int i = 0;i < n;i++) {
            if (in[i]) continue;
            move_inside(i);
            if (press_button() > mid) {
                move_outside(i);
            }
            else in[i] = mid, cnt++;
        }
        if (cnt < type * sz) {
            r = mid - 1;
            for (int i = 0;i < n;i++) if (in[i] == mid) move_outside(i), in[i] = 0;
        }
        else l = mid;
    }
    return l;
    // n , n , n
    /*
        ans <= n / type
        ans <= n - mx
    */
    return -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 Incorrect 0 ms 344 KB Wrong answer.
5 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 Incorrect 0 ms 344 KB Wrong answer.
5 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 340 KB Output is correct
6 Incorrect 0 ms 344 KB Wrong answer.
7 Halted 0 ms 0 KB -