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])
{
ind[i]=0;
ni[i]=1;
}
else
ni[i]=0;
}
cnt=0;
}
}
return st;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
11 ms |
344 KB |
Output is correct |
8 |
Correct |
14 ms |
344 KB |
Output is correct |
9 |
Correct |
19 ms |
344 KB |
Output is correct |
10 |
Partially correct |
46 ms |
344 KB |
Output is partially correct |
11 |
Correct |
23 ms |
344 KB |
Output is correct |
12 |
Correct |
18 ms |
344 KB |
Output is correct |
13 |
Incorrect |
36 ms |
344 KB |
Wrong answer. |
14 |
Halted |
0 ms |
0 KB |
- |