比赛 20100420 评测结果 AAATTTT
题目名称 圆桌会议B 最终得分 42
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-04-20 10:58:21
显示代码纯文本
program t1;
type
  t=array[1..40] of integer;
var
  ans:array[1..10000] of t;
  a:t;
  b:array[1..40] of boolean;
  like:array[1..40,1..40] of boolean;
  n,c,k,i,j,r:integer;
procedure dfs(step,last:integer);
var
  i,j1,j2:integer;
  bool,bool2:boolean;
begin
  for i:=1 to n do
    if (b[i]) and (like[last,i]) and (like[i,last]) then
    begin
      a[step]:=i;
      if step=n then
      begin
        if (like[i,1]) and (like[1,i]) then
        begin
          bool2:=true;
          for j1:=1 to k do
          begin
            bool:=false;
            for j2:=2 to n do
              if a[j2]<>ans[j1,n+2-j2] then
              begin
                bool:=true;
                break
              end;
            if bool=false then
            begin
              bool2:=false;
              break
            end
          end;
          if bool2 then
          begin
            inc(k);
            ans[k]:=a;
          end
        end
      end
      else
      begin
        b[i]:=false;
        dfs(step+1,i);
        b[i]:=true;
      end;
    end
end;

begin
  assign(input,'dislike.in');
  reset(input);
  assign(output,'dislike.out');
  rewrite(output);
  repeat
    read(c);
    if c=0
      then break;
    if c>1
      then writeln;
    readln(n);
    for i:=1 to n do
      for j:=1 to n do
      begin
        read(r);
        if r=1
          then like[i,j]:=false
          else like[i,j]:=true;
      end;
    k:=0;
    fillchar(b,sizeof(b),true);
    b[1]:=false;
    a[1]:=1;
    dfs(2,1);
    writeln(c,' ',k);
    if k>0 then
    begin
      for i:=1 to k do
      begin
        for j:=1 to n do
          write(ans[i,j],' ');
        writeln
      end
    end;
  until false;
  close(input);
  close(output);
end.