# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629049 | two_sides | Rarest Insects (IOI22_insects) | C++17 | 178 ms | 444 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;
set<int> inside;
void insert(int i) {
inside.insert(i);
move_inside(i);
}
void erase(int i) {
inside.erase(i);
move_outside(i);
}
}
int min_cardinality(int n) {
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)) {
insert(i);
if (press_button() > m) erase(i);
else {
last.push_back(i);
if (inside.size() == m * t) break;
}
}
if (inside.size() == m * t) 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... |