Submission #886088

# Submission time Handle Problem Language Result Execution time Memory
886088 2023-12-11T12:52:57 Z thinknoexit Rarest Insects (IOI22_insects) C++17
0 / 100
22 ms 972 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
int in[2020];
set<int> candidate;
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);
            candidate.insert(i);
        }
        else in[i] = 1, type++;
    }
    if (type == 1) return n;
    int mxans = n / type;
    int l = 1, r = mxans;
    int ans = 1;
    int sz = type;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        stack<int> s;
        for (auto i : candidate) {
            move_inside(i);
            if (press_button() > mid) move_outside(i);
            else in[i] = 1, s.push(i), sz++;
        }
        if (sz < type * mid) {
            if (r == l + 1) return l;
            while (!s.empty()) {
                in[s.top()] = 0;
                move_outside(s.top());
                sz--;
                s.pop();
            }
            r = mid - 1;
        }
        else {
            while (!s.empty()) candidate.erase(s.top()), s.pop();
            ans = mid;
            l = mid + 1;
        }
    }
    return ans;
}
# 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 1 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Incorrect 4 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 1 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Incorrect 4 ms 344 KB Wrong answer.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 0 ms 344 KB Output is correct
7 Correct 11 ms 972 KB Output is correct
8 Correct 8 ms 600 KB Output is correct
9 Incorrect 22 ms 728 KB Wrong answer.
10 Halted 0 ms 0 KB -