# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893132 | Trisanu_Das | Rarest Insects (IOI22_insects) | C++17 | 48 ms | 1116 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 <bits/stdc++.h>
#include "insects.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int min_cardinality(int N) {
vector <int> rest;
auto attempt = [&](int x, int v) {
move_inside(x);
if (press_button() != v) rest.push_back(x), move_outside(x);
};
for (int i = 0; i < N; i++) attempt(i, 1);
int ans = 1, cnt = N - (int)rest.size();
for (; !rest.empty(); ans++) {
vector <int> tmp = rest;
rest.clear();
shuffle(tmp.begin(), tmp.end(), rng);
for (int i = 0; i < tmp.size(); i++)
if (i < rest.size() + cnt) attempt(tmp[i], ans + 1);
else rest.push_back(tmp[i]);
if (tmp.size() < rest.size() + cnt) break;
}
return ans;
}
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... |