# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078170 | Muhammad_Aneeq | Rarest Insects (IOI22_insects) | C++17 | 64 ms | 852 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.
void move_inside(int i);
void move_outside(int i);
int press_button();
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
set<int>ind;
int min_cardinality(int N)
{
int colors=0;
for (int i=0;i<N;i++)
{
move_inside(i);
ind.insert(i);
if (press_button()==2)
{
move_outside(i);
ind.erase(i);
}
else
colors++;
}
set<int>ni;
for (int i=0;i<N;i++)
if (ind.find(i)==ind.end())
ni.insert(i);
if (colors==1)
return N;
int st=1,en=N/colors+1;
while (st+1<en)
{
int mid=(st+en)/2;
for (auto i:ni)
{
if (ind.size()==colors*mid)
break;
move_inside(i);
ind.insert(i);
if (press_button()>mid)
{
move_outside(i);
ind.erase(i);
}
}
if (ind.size()==mid*colors)
{
for (auto i:ind)
ni.erase(i);
st=mid;
}
else
{
en=mid;
ni.clear();
for (auto i:ind)
{
ni.insert(i);
move_outside(i);
}
ind.clear();
}
}
return st;
}
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... |