# Party Lamps_usaco2.2.4_暴力?

10
1
-1
7 -1

## 樣例輸出 Sample Output

0000000000
0101010101
0110110110

1,4,7,10號燈關著，2,3,5,6,8,9亮著

1,3,5,7,9號燈關著，2, 4, 6, 8, 10亮著

## 程式碼 Code

``````/*
ID:wjp13241
PROG:lamps
LANG:C
*/
#include <stdio.h>
#include <cstring>
using namespace std;
int t[8]={0,28,42,54,9,21,35,63};
int steps[8]={1,2,1,2,1,1,2,0};
int f[7];
int n,m;
int get(int x)
{
return !(x%6)?6:x%6;
}
void print(int x)
{
memset(f,0,sizeof(f));
do{
f[  f[0]]=x%2;
}while(x/=2);
f[0]=6;
for (int i=1;i<=n;i  )
printf("%d",f[get(i)]);
printf("\n");
}
int main()
{
freopen("lamps.in","r",stdin);
freopen("lamps.out","w",stdout);
int tmp,on=0,off=0,cnt1=0,cnt2=0;
scanf("%d%d",&n,&m);
while (scanf("%d",&tmp)&&tmp!=-1)
on=on|(1<<(get(tmp)-1)),cnt1  ;
while (scanf("%d",&tmp)&&tmp!=-1)
off=off|(1<<(get(tmp)-1)),cnt2  ;
if (!m)
{
if (cnt1==n)
while (n--)
printf("0");
else
if (!cnt2)
while (n--)
printf("1");
else
if (cnt2)
printf("IMPOSSIBLE");
printf("\n");
return 0;
}
bool flag=false;
for (int i=0;i<8;i  )
{
int a=on&t[i];
int b=off&t[i];
if (!b&&(a==on)&&m>steps[i])
{
print(t[i]);
flag=true;
}
}
if (!flag)
printf("IMPOSSIBLE\n");
fclose(stdin);
fclose(stdout);
return 0;
}``````