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>
using namespace std;
int min_cardinality(vector<int> x)
{
if (x.size() == 1)
return 1;
if (x.empty())
return 0;
vector<int>v;
for (int i : x)
{
v.push_back(i);
move_inside(i);
int k = press_button();
if (k == 2)
{
v.pop_back();
move_outside(i);
}
}
if (v.size() * 2 > x.size())
return 1;
set<int> X(v.begin(), v.end());
for (int i : v)
move_outside(i);
reverse(x.begin(), x.end());
for (int i : x)
{
v.push_back(i);
move_inside(i);
int k = press_button();
if (k == 2)
{
v.pop_back();
move_outside(i);
}
}
for (int i : v)
move_outside(i);
set<int> Y(v.begin(), v.end());
for (int i : X)
if (Y.find(i) != Y.end())
return 1;
set<int>S;
for (int i : X)
S.erase(i);
for (int i : Y)
S.erase(i);
return 2 + min_cardinality(vector<int>(S.begin(), S.end()));
}
int min_cardinality(int N) {
vector<int>v;
for (int i = 0; i < N; i++)
v.push_back(i);
return min_cardinality(v);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |