比赛 暑假培训二 评测结果 AAAAAAAATT
题目名称 跳棋的挑战 最终得分 80
用户昵称 Hamster 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-18 11:12:02
显示代码纯文本
program checker;
var
  i,n,s,q:integer;
  z:longint;
  a:array[1..13] of 0..1;
  b:array[2..26] of 0..1;
  c:array[-12..12] of 0..1;
  x:array[1..13] of integer;
  fin,fout:text;

procedure init;
begin
  for i:=1 to 13 do
  begin
    a[i]:=0;
    x[i]:=0;
  end;
  for i:=2 to 26 do b[i]:=0;
  for i:=-12 to 12 do c[i]:=0;
  z:=0;
end;

procedure search(i:integer);
var
  j:integer;
begin
  for j:=1 to n do
    if (a[j]=0) and (b[i+j]=0) and (c[i-j]=0) then
    begin
      x[i]:=j;
      a[j]:=1;
      b[i+j]:=1;
      c[i-j]:=1;
      if i<n then search(i+1)
      else
      begin
        inc(z);
        if z<4 then
        begin
          for q:=1 to n do write(fout,x[q],' ');
          writeln(fout);
        end;
      end;
      a[j]:=0;
      b[i+j]:=0;
      c[i-j]:=0;
    end;
end;

begin
  assign(fin,'checker.in');
  reset(fin);
  assign(fout,'checker.out');
  rewrite(fout);

  readln(fin,n);
  init;
  search(1);
  writeln(fout,z);

  close(fin);
  close(fout);
end.