比赛 20120612 评测结果 RRRRR
题目名称 灯光 最终得分 0
用户昵称 wo shi 刘畅 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-06-12 19:20:18
显示代码纯文本
var
  tot,i,n,c,l:longint;
  liang,an,b:array[-1..100000]of boolean;
  ans:array[-1..100000]of string;


function ok:boolean;
var
  i:longint;
begin
  for i:=1 to n do
  begin
    if (not b[i])and(liang[i]) then exit(false);
    if (b[i])and(an[i]) then exit(false);
  end;
  ok:=true;
end;

procedure go(k:longint);
var
  i:longint;
  now:array[0..100000]of boolean;
begin
  if k>c then
  begin
    if ok then
    begin
      inc(tot);
      ans[tot]:='';
      for i:=1 to n do
      if b[i] then ans[tot]:=ans[tot]+'1'
      else ans[tot]:=ans[tot]+'0';
    end;
    exit;
  end;
  for i:=1 to n do now[i]:=b[i];

    for i:=1 to n do
    b[i]:=not b[i];
    go(k+1);

  for i:=1 to n do b[i]:=now[i];

    for i:=1 to n do
    if i mod 2=1 then b[i]:=not b[i];
    go(k+1);

  for i:=1 to n do b[i]:=now[i];

    for i:=1 to n do
    if i mod 2=0 then b[i]:=not b[i];
    go(k+1);

  for i:=1 to n do b[i]:=now[i];
    for i:=1 to n do
    if i mod 3=1 then b[i]:=not b[i];
    go(k+1);
end;

procedure sort(l,r:longint);
var
  i,j:longint;
  x,y:string;
begin
  i:=l;
  j:=r;
  x:=ans[(l+r) div 2];
  repeat
    while ans[i]<x do inc(i);
    while x<ans[j] do dec(j);
    if i<=j then
    begin
      y:=ans[i];
      ans[i]:=ans[j];
      ans[j]:=y;
      inc(i);
      dec(j);
    end;
  until i>j;
  if i<r then sort(i,r);
  if l<j then sort(l,j);
end;

begin
  assign(input,'partya.in'); reset(input);
  assign(output,'partyb.out'); rewrite(output);
  readln(n);
  readln(c);
  read(l);
  if l<>-1 then
  repeat
    liang[l]:=true;
    read(l);
  until l=-1;

  read(l);
  if l<>-1 then
  repeat
    an[l]:=true;
    read(l);
  until l=-1;

  while c>4 do dec(c,2);

  for i:=1 to n do b[i]:=true;

  go(1);

  sort(1,tot);
  for i:=1 to tot do
  if ans[i]<>ans[i-1] then writeln(ans[i]);
  close(input);
  close(output);
end.