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>
#include <bitset>
using namespace std;
int const MAXN=2000;
bitset<MAXN>ind,ni;
int min_cardinality(int N)
{
int colors=0;
for (int i=0;i<N;i++)
{
move_inside(i);
ind[i]=1;
if (press_button()==2)
{
move_outside(i);
ind[i]=0;
}
else
colors++;
}
for (int i=0;i<N;i++)
ni[i]=1-ind[i];
if (colors==1)
return N;
int st=1,en=N/colors+1;
int cnt=colors;
while (st+1<en)
{
int mid=(st+en)/2;
for (int i=0;i<N;i++)
{
if (cnt==mid*colors)
break;
if (ni[i])
{
move_inside(i);
ind[i]=1;
if (press_button()>mid)
{
ind[i]=0;
move_outside(i);
}
else
{
cnt++;
ni[i]=0;
}
}
}
if (cnt==mid*colors)
st=mid;
else
{
en=mid;
for (int i=0;i<N;i++)
{
if (ind[i])
{
move_outside(i);
ind[i]=0;
ni[i]=1;
}
else
ni[i]=0;
}
cnt=0;
}
}
return st;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |