# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078362 | allin27x | Rarest Insects (IOI22_insects) | C++17 | 40 ms | 1096 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;
#define int long long
//void move_inside(int)
//void move_outside(int)
// int press_button()
signed min_cardinality(signed N){
std::random_device rd;
std::mt19937 g(rd());
vector<int> in,out; int k;
for (int i=0; i<N; i++) {
move_inside(i);
if (press_button() == 2) move_outside(i);
else in.push_back(i);
}
k = in.size(); for (int x: in) move_outside(x);
int ans = 0;
vector<int> tot; for (int i=0; i<N; i++) tot.push_back(i);
while (1) {
int mx = (int)tot.size()/k;
if (!mx) return ans;
int m = mx / 2+1;
in.clear(); out.clear();
shuffle(tot.begin(), tot.end(), g);
for (int x: tot) {
move_inside(x);
if (in.size() == m*k || press_button() == m+1) move_outside(x), out.push_back(x);
else in.push_back(x);
}
if (in.size() == m * k) {
ans += m; tot = out;
} else {
tot = in;
}
for (int x: in) move_outside(x);
}
}
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... |