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 <vector>
#include <iostream>
using namespace std;
int get_min(vector<int> vc, int spec)
{
if (spec == 1) return vc.size();
int mx = vc.size() / spec;
vector<bool> u(vc.size());
vector<int> toremove;
for (int i = 0; i < (int)vc.size(); i++) {
move_inside(vc[i]);
if (press_button() > mx) {
move_outside(vc[i]);
u[i] = true;
}
else toremove.push_back(vc[i]);
}
for (int i:toremove) move_outside(i);
toremove.clear();
int cnt = 0;
for (int i = 0; i < (int)vc.size(); i++) {
if (!u[i]) continue;
move_inside(vc[i]);
if (press_button() > 1) {
move_outside(vc[i]);
}
else {
toremove.push_back(vc[i]);
cnt++;
}
}
for (int i = 0; i < (int)vc.size(); i++) {
if (u[i]) continue;
move_inside(vc[i]);
if (press_button() > 1) u[i] = true;
move_outside(vc[i]);
}
for (int i:toremove) move_outside(i);
vector<int> nxt;
for (int i = 0; i < (int)vc.size(); i++) {
if (!u[i]) nxt.push_back(vc[i]);
}
if (nxt.size() == vc.size()) return mx;
else return get_min(nxt, spec - cnt);
}
int min_cardinality(int N) {
vector<int> vc;
for (int i = 0; i < N; i++) vc.push_back(i);
int cnt = 0;
vector<int> toremove;
for (int i = 0; i < N; i++) {
move_inside(i);
if (press_button() >= 2) {
move_outside(i);
}
else {
toremove.push_back(i);
cnt++;
}
}
for (int i:toremove) move_outside(i);
return get_min(vc, cnt);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |