记录编号 16125 评测结果 WAAETTE
题目名称 圆桌会议B 最终得分 28
用户昵称 Gravatarreamb 是否通过 未通过
代码语言 Pascal 运行时间 2.158 s
提交时间 2010-04-20 18:12:58 内存使用 1.68 MiB
显示代码纯文本
program yuanzhuohuiyi;
var
  e,c,n,i,p,t,r,z,u,min:longint;
  a:array[1..41,1..41]of integer;
  q:array[1..41] of integer;
  biaozhi:array[1..41] of boolean;
  jilu:array[1..10000,1..41]of longint;
procedure sousuo(k:integer);
var
  j:integer;
begin
  for j:=1 to n do
    if (a[q[k-1],j]=0) and (a[j,q[k-1]]=0)
    and biaozhi[j]=true then
    begin
      biaozhi[j]:=false;
      q[k]:=j;
      if k=n then
      begin
        if (a[j,1]=0)and(a[1,j]=0)and(j>q[2]) then
        begin
          t:=t+1;
          for z:=1 to n do
            jilu[t,z]:=q[z]
        end
      end
      else
          sousuo(k+1);
      biaozhi[j]:=true
    end
end;
begin
  assign (input,'dislike.in');
  reset (input);
  assign (output,'dislike.out');
  rewrite (output);
    readln (c,n);
    while c<>0 do
    begin
      min:=maxlongint;
      for i:=1 to n do
      begin
        r:=0;
        for p:=1 to n do
        begin
          if  a[i,p]=0 then
            r:=r+1;
          read (a[i,p]);
        end;
        if r<min then
        min:=r;
        readln
      end;
        if min>=2 then
        begin
          for i:=2 to n do
            if (a[1,i]=0) and (a[i,1]=0) then
            begin
              q[1]:=1;
              q[2]:=i;
              for e:=1 to n do
                biaozhi[e]:=true;
              biaozhi[1]:=false;
              biaozhi[i]:=false;
              sousuo(3);
            end;
          writeln (c,' ',t);
          for z:=1 to t do
          begin
            for u:=1 to n do
              write (jilu[z,u],' ');
            writeln
          end;
          t:=0
        end
        else
          writeln ('0');
        readln (c,n)
    end;
  close (input);
  close (output)
end
.