比赛 暑假培训二 评测结果 AAAAATTATT
题目名称 跳棋的挑战 最终得分 60
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-18 11:41:07
显示代码纯文本
program checker;
type
fxz1=array[1..15,1..15]of integer;
fxz2=array[1..15]of integer;
var
chess:fxz1;
way:fxz2;
f1,f2:text;
n,step,i,j:longint;
procedure queen(board:fxz1;x:integer;var step:longint);
var
i,j,a,b:longint;
begin
for i:=1 to n do
  if board[x,i]=0 then begin
                     inc(board[x,i]);way[x]:=i;
                     for j:=1 to n do begin inc(board[x,j]);inc(board[j,i])end;
                     a:=x;b:=i;while (a<=n)and(b<=n) do begin inc(board[a,b]);inc(a);inc(b);end;
                     a:=x;b:=i;while (a<=n)and(b>=1) do begin inc(board[a,b]);inc(a);dec(b);end;
                     a:=x;b:=i;while (a>=1)and(b<=n) do begin inc(board[a,b]);dec(a);inc(b);end;
                     a:=x;b:=i;while (a>=1)and(b>=1) do begin inc(board[a,b]);dec(a);dec(b);end;
                     if x<n then queen(board,x+1,step)
                     else begin inc(step);if step<=3 then begin for j:=1to n do write(f2,way[j],' ');writeln(f2);end;end;
                     for j:=1 to n do begin dec(board[x,j]);dec(board[j,i]);end;
                     a:=x;b:=i;while (a<=n)and(b<=n) do begin dec(board[a,b]);inc(a);inc(b);end;
                     a:=x;b:=i;while (a<=n)and(b>=1) do begin dec(board[a,b]);inc(a);dec(b);end;
                     a:=x;b:=i;while (a>=1)and(b<=n) do begin dec(board[a,b]);dec(a);inc(b);end;
                     a:=x;b:=i;while (a>=1)and(b>=1) do begin dec(board[a,b]);dec(a);dec(b);end;
                     end;


end;
begin
assign(f1,'checker.in');
assign(f2,'checker.out');
reset(f1);rewrite(f2);
readln(f1,n);
for i:=1 to n do
 for j:=1 to n do
chess[i,j]:=0;
step:=0;
queen(chess,1,step);
writeln(f2,step);
close(f1);close(f2);
end.