# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629057 | two_sides | Rarest Insects (IOI22_insects) | C++17 | 49 ms | 440 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>
namespace {
using namespace std;
mt19937 rng(chrono::high_resolution_clock
::now().time_since_epoch().count());
set<int> inside, useless;
vector<int> ord;
void insert(int i) {
inside.insert(i);
move_inside(ord[i]);
}
void erase(int i) {
inside.erase(i);
move_outside(ord[i]);
}
}
int min_cardinality(int n) {
ord.resize(n);
iota(ord.begin(), ord.end(), 0);
shuffle(ord.begin(), ord.end(), rng);
for (int i = 0; i < n; i++) {
insert(i);
if (press_button() > 1) erase(i);
}
int t = inside.size();
int l = 1, r = n / t;
while (l < r) {
int m = (l + r + 1) / 2;
vector<int> last;
for (int i = 0; i < n; i++)
if (!inside.count(i) && !useless.count(i)) {
insert(i);
if (press_button() > m) {
erase(i); useless.insert(i);
} else {
last.push_back(i);
if (inside.size() == m * t) break;
}
}
if (inside.size() == m * t) {
for (int i : inside)
useless.erase(i);
l = m;
} else {
for (int i : last) erase(i);
r = m - 1;
}
}
return r;
}
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... |