暴力,不可能,肯定炸…怎么办呀,发现同一个按钮按两次就相当于没按QAQ
var i,j,k:longint;
i1,i2,i3,i4:longint;
m,n,c:longint;
a:array[-1..1000]of longint;
b:array[0..1000]of longint;
s:array[0..1000]of string;
sum:longint;
procedure new;//还原呀QAQ
var i:longint;
begin
for i:=1 to n do b[i]:=1;
end;
function pd:boolean;//判断是不是解
var i:longint;
begin
for i:=1 to n do if a[i]<>2 then
begin
if a[i]<>b[i] then exit(false);
end;
exit(true);
end;
begin
read(n);
read(c);
for i:=1 to n do a[i]:=2;
while m<>-1 do
begin
read(m);
a[m]:=1;
end;
m:=0;
while m<>-1 do
begin
read(m);
a[m]:=0;
end;
//枚举
for i1:=0 to 1 do
for i2:=0 to 1 do
for i3:=0 to 1 do
for i4:=0 to 1 do
begin
if ((i1+i2+i3+i4) mod 2=c mod 2) and (c>=i1+i2+i3+i4) then
begin
new;
if i1=1 then//如果第一个打开
begin
for i:=1 to n do b[i]:=(b[i]+1) mod 2;
end;
if i2=1 then//如果第二个打开
begin
for i:=1 to n do if i mod 2=1 then b[i]:=(b[i]+1) mod 2;
end;
if i3=1 then//如果第三个打开
begin
for i:=1 to n do if i mod 2=0 then b[i]:=(b[i]+1) mod 2;
end;
if i4=1 then//4....
begin
for i:=0 to n div 3+1 do b[i*3+1]:=(b[i*3+1]+1) mod 2;
end;
if pd then
begin
inc(sum);
for i:=1 to n do
s[sum]:=s[sum]+chr(b[i]+48);
end;
end;
end;
for i:=1 to sum-1 do//排序
for j:=1 to sum-i do
if s[j]>s[j+1] then
begin
s[0]:=s[j];
s[j]:=s[j+1];
s[j+1]:=s[0];
end;
if sum=0 then writeln('IMPOSSIBLE');//无解呀QAQ
for i:=1 to sum do writeln(s[i]);//有解呀QAQ
end.//不难呀QwQ
这题不是很难呀,主要考的是细心