# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
776321 | GusterGoose27 | Rarest Insects (IOI22_insects) | C++17 | 329 ms | 208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int min_cardinality(int n) {
vector<int> perm(n);
iota(perm.begin(), perm.end(), 0);
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
for (int i = 1; i < n; i++) swap(perm[i], perm[gen()%(i+1)]);
vector<int> reps;
vector<int> extra;
move_inside(perm[0]);
int num_inside = 1;
for (int i = 1; i < n; i++) {
move_inside(perm[i]);
if (press_button() > 1) {
move_outside(perm[i]);
extra.push_back(perm[i]);
}
else {
num_inside++;
}
}
int k = num_inside;
if (k == 1) return n;
while (extra.size() >= k) {
int s = extra.size()/k/2;
int base = num_inside/k;
vector<int> l, r;
for (int i = 0; i < s; i++) {
move_inside(extra[i]);
l.push_back(extra[i]);
}
for (int i = s; i < extra.size(); i++) {
move_inside(extra[i]);
if (press_button() > s+base) {
move_outside(extra[i]);
r.push_back(extra[i]);
}
else {
l.push_back(extra[i]);
}
}
if (l.size() == s*k) {
extra = r;
num_inside += l.size();
}
else {
extra = l;
for (int v: l) move_outside(v);
}
}
return num_inside/k;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |