比赛 暑假培训七 评测结果 AAATTT
题目名称 过河卒 最终得分 30
用户昵称 Oo湼鞶oO 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 17:11:13
显示代码纯文本
{*******************************************}
{* Program Name: Pj024                     *}
{* Input File: pj024.in                    *}
{* Output File: pj024.out                  *}
{* Date: 2008.7.24                         *}
{* Programmer: Peng Bo                     *}
{*******************************************}
program pj024;
type
  sz=array[0..20,0..20]of boolean;
  jl=record
    x,y:byte;
    end;
var
  s:sz;
  n,m:jl;
  g:longint;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure input;
var
  f:text;
begin
  assign(f,'pj024.in');
  reset(f);
  read(f,n.x,n.y,m.x,m.y);
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
  f:text;
begin
  assign(f,'pj024.out');
  rewrite(f);
  write(f,g);
  close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure  cs;
var
  j,k:byte;
begin
  g:=0;
  for j:=0 to n.x do
    for k:=0 to n.y do
      s[j,k]:=true;
  s[m.x,m.y]:=false;
  if m.x+2<=n.x
  then
  begin
    if m.y-1>=0
    then
      s[m.x+2,m.y-1]:=false;
    if m.y+1<=n.y
    then
      s[m.x+2,m.y+1]:=false;
  end;
  if m.x-2>=0
  then
  begin
    if m.y-1>=0
    then
      s[m.x-2,m.y-1]:=false;
    if m.y+1<=n.y
    then
      s[m.x-2,m.y+1]:=false;
  end;
  if m.y+2<=n.y
  then
  begin
    if m.x-1>=0
    then
      s[m.x-1,m.y+2]:=false;
    if m.x+1<=n.x
    then
      s[m.x+1,m.y+2]:=false;
  end;
  if m.y-2>=0
  then
  begin
    if m.x-1>=0
    then
      s[m.x-1,m.y-2]:=false;
    if m.x+1<=n.x
    then
      s[m.x+1,m.y-2]:=false;
  end;
  for j:=0 to n.x do
  begin
    for k:=0 to n.y do
      write(s[j,k]:5,',');
    writeln;
  end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main(x,y:byte);
var
  i:boolean;
begin
  if (x=n.x)and(y=n.y)
  then
    inc(g);
  if (x>=0)and(y>=0)and(x<=n.x)and(y<=n.y)and(s[x,y])
  then
    for i:=false to true do
      if i
      then
        main(x+1,y)
      else
        main(x,y+1);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
  input;
  cs;
  main(0,0);
  output;
end.
{End.}