/*
ID:18861501
LANG:C++
TASK:lamps
*/
/*------------------Header Files------------------*/
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctype.h>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <limits.h>
using namespace std;
/*------------------Definitions-------------------*/
#define LL long long
#define PI acos(-1.0)
#define INF 0x3F3F3F3F
/*---------------------Work-----------------------*/
//首先要明白同一个按钮,按两次的效果是一样的,所以共有16种方案
//其次所按的次序可以无视,且16种方案可以压缩到8种,所以可以打表(常量数组)(按从小到大排列)
//因为1+2+3=不按,但是这里并不考虑如:一次按键完成所有均为1的情况;三次实现2或3或4的情况(体现只需要过后台数据即可)!!
//这个电力系统有一个性质:每6个灯是一个循环!!!,所以只需将要求压缩至前六个即可(重视思维!!!)
//当自相矛盾时可以直接输出:IMPOSSIBLE
//要多注意求模得到0的情况分别考虑
int light[9][7]=
{
0,0,0,0,0,0,0,
0,0,0,0,0,0,0, //1
0,0,0,1,1,1,0, //2 and 4
0,0,1,0,1,0,1, //3
0,0,1,1,0,1,1, //4
0,1,0,0,1,0,0, //1 and 4
0,1,0,1,0,1,0, //2
0,1,1,0,0,0,1, //3 and 4
0,1,1,1,1,1,1, //no
};
int minnum[9]= {0,1,2,1,1,2,1,2,0};
int N,C;
int on[110],off[110];
int want[7];
void work()
{
scanf("%d%d",&N,&C);
int cnt=1;
while(1)
{
scanf("%d",&on[cnt]);
if(on[cnt]==-1) break;
cnt++;
}
cnt--;
memset(want,-1,sizeof(want));
for(int i=1; i<=cnt; i++)
{
int n;
if(on[i]%6==0) n=6;
else n=on[i]%6;
if(want[n]==-1) want[n]=1;
}
cnt=1;
while(1)
{
scanf("%d",&off[cnt]);
if(off[cnt]==-1) break;
cnt++;
}
cnt--;
for(int i=1; i<=cnt; i++)
{
int n;
if(off[i]%6==0) n=6;
else n=off[i]%6;
if(want[n]==-1) want[n]=0;
if(want[n]==1)
{
printf("IMPOSSIBLE\n");
return;
}
}
bool flag_all=false;
for(int i=1; i<=8; i++)
{
bool flag=true;
for(int j=1; j<=6; j++)
{
if(want[j]!=light[i][j]&&want[j]!=-1)
{
flag=false;
break;
}
}
if(flag&&minnum[i]<=C)
{
flag_all=true;
for(int j=1; j<=N; j++)
{
if(j%6==0) printf("%d",light[i][6]);
else printf("%d",light[i][j%6]);
}
printf("\n");
}
}
if(!flag_all) printf("IMPOSSIBLE\n");
}
/*------------------Main Function------------------*/
int main()
{
//freopen("test.txt","r",stdin);
freopen("lamps.out","w",stdout);
freopen("lamps.in","r",stdin);
work();
return 0;
}
2.2.4(wonderful)
最新推荐文章于 2024-06-17 17:14:32 发布