Submission #886551

# Submission time Handle Problem Language Result Execution time Memory
886551 2023-12-12T10:09:40 Z thinknoexit Rarest Insects (IOI22_insects) C++17
0 / 100
2 ms 600 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
int n;
int sz = 0;
set<int> rem;
void putin(int x) {
    move_inside(x);
    sz++;
}
void putout(int x) {
    move_outside(x);
    sz--;
}
int val() {
    return press_button();
}
int min_cardinality(int N) {
    n = N;
    putin(0);
    for (int i = 1;i < n;i++) {
        putin(i);
        if (val() == 2) {
            putout(i);
            rem.insert(i);
        }
    }
    int type = sz;
    if (type == n) return 1;
    int ans = 1;
    int l = 1, r = n / sz;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        stack<int> st, st2;
        for (auto& x : rem) {
            putin(x);
            if (val() > mid) {
                putout(x);
                st2.push(x);
            }
            else {
                st.push(x);
            }
        }
        if (sz == type * mid) {
            while (!st.empty()) {
                rem.erase(st.top());
                st.pop();
            }
            while (!st2.empty()) {
                putin(st2.top());
                rem.erase(st2.top());
                st2.pop();
            }
            ans = mid;
            l = mid + 1;
        }
        else {
            while (!st.empty()) {
                putout(st.top());
                st.pop();
            }
            r = 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 Incorrect 2 ms 600 KB Wrong answer.
7 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 Incorrect 2 ms 600 KB Wrong answer.
7 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 1 ms 340 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 -