Submission #1025122

# Submission time Handle Problem Language Result Execution time Memory
1025122 2024-07-16T16:17:20 Z vjudge1 Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;

#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int) s.size()
#define s second 
#define f first 

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

mt19937_64 rng(131415889);

int min_cardinality(int n) {
    vector<int> p(n), pos;
    for (int i = 0; i < n; i++) p[i] = i;
    shuffle(all(p), rng);
    int k = 0;
    for (int i = 0; i < sz(p); i++) {
        move_inside(p[i]);
        if (press_button() == 1) {
            k++;
            pos.push_back(p[i]);
        }else move_outside(p[i]);
    }
    for (int x: pos) move_outside(x);
    int l = 1, r = n, ans = 0;
    while (l <= r) {
        int m = (l + r) / 2;
        vector<int> s0, s1;
        for (int i = 0; i < sz(p); i++) {
            move_inside(p[i]);
            if (press_button() > m) {
                move_outside(p[i]);
                s1.push_back(p[i]);
            }else s0.push_back(p[i]);
            if (sz(s0) == m * k) break;
        }
        for (int x: s0) move_outside(x);
        if (sz(s0) == m * k) {
            p = s1;
            l = 1;
            r -= m;
            ans += m;
        }else p = s0, r = m - 1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -