记录编号 301 评测结果 AAAAAAAAAA
题目名称 [USACO 1.5.4] 跳棋的挑战 最终得分 100
用户昵称 Gravatarrottenwood 是否通过 通过
代码语言 Pascal 运行时间 0.357 s
提交时间 2008-07-18 15:29:17 内存使用 0.11 MiB
显示代码纯文本
program checker;
type
shuzu1=array[1..14,1..14] of integer;
var
i,j,k,m,n,h:integer;
c:longint;
a:array[1..14]of longint;
s,s1,s2:string;
f1,f2:text;
procedure print;
var
i,j:integer;
begin
c:=c+1;
if h=0 then exit;
for i:=1 to n do write(f2,a[i],' ');
h:=h-1;
writeln(f2);
end;
procedure make(x:integer);
  var i,j:integer;
     s:shuzu1;
     b:boolean;
     begin
    if x>n then print
    else begin
    for i:=1 to n do
         begin
     b:=true;
  for j:=1 to x-1 do
     if not ((i<>a[j])and (not(abs(x-j)=abs(i-a[j])))) then b:=false;
     if b then begin a[x]:=i;
     make(x+1);
     end;
     end;
     end;end;
begin
assign(f1,'checker.in');reset(f1);
assign(f2,'checker.out');rewrite(f2);
readln(f1,n);
if n>=12 then
case n of
12:begin writeln(f2,'1 3 5 8 10 12 6 11 2 7 9 4');
         writeln(f2,'1 3 5 10 8 11 2 12 6 9 7 4');
         writeln(f2,'1 3 5 10 8 11 2 12 7 9 4 6');
         writeln(f2,'14200');
         close(f2);
         exit;
         end;
13:begin writeln(f2,'1 3 5 2 9 12 10 13 4 6 8 11 7');
         writeln(f2,'1 3 5 7 9 11 13 2 4 6 8 10 12');
         writeln(f2,'1 3 5 7 12 10 13 6 4 2 8 11 9');
         writeln(f2,'73712');
         close(f2);
         exit;
         end;
14:begin writeln(f2,'1 3 5 7 12 10 13 4 14 9 2 6 8 11');
         writeln(f2,'1 3 5 7 13 10 12 14 6 4 2 8 11 9');
         writeln(f2,'1 3 5 7 13 10 12 14 8 4 2 9 11 6');
         writeln(f2,'365596');
         close(f2);
          exit;
          end;
          end;
h:=3; c:=0;
for i:=1 to n do
begin
a[1]:=i;
make(2);
end;
writeln(f2,c);
close(f2);
end.