比赛 |
暑假培训七 |
评测结果 |
AAAEEE |
题目名称 |
过河卒 |
最终得分 |
30 |
用户昵称 |
rottenwood |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-24 17:15:10 |
显示代码纯文本
program pj024;
type
shuzu=array[-2..100,-2..100] of integer;
shuzu1=array[1..8] of integer;
var
xx,yy:shuzu1;
s:shuzu;
i,j,m,n,x,y:integer;
f1,f2:text;
flag:boolean;
begin
assign(f1,'pj024.in');reset(f1);
assign(f2,'pj024.out');rewrite(f2);
readln(f1,n,m,x,y);
xx[1]:=-2;xx[2]:=-1;xx[3]:=1;xx[4]:=2;xx[5]:=2;xx[6]:=1;xx[7]:=-1;xx[8]:=-2;
yy[1]:=1;yy[2]:=2;yy[3]:=2;yy[4]:=1;yy[5]:=-1;yy[6]:=-2;yy[7]:=-2;yy[8]:=-1;
for i:=1 to 8 do
begin
s[x+xx[i],y+yy[i]]:=-1;
end;
for i:=1 to n do
if s[i,0]<>-1 then s[i,0]:=1 else break;
for j:=1 to m do
if s[0,j]<>-1 then s[0,j]:=1 else break;
s[x,y]:=-1;
s[0,0]:=1;
for i:=1 to n do
for j:=1 to m do
begin
if (s[i,j]<>-1)and(s[i-1,j]<>-1)and(s[i,j-1]<>-1) then s[i,j]:=s[i-1,j]+s[i,j-1];
if (s[i,j]<>-1)and(s[i-1,j]=-1)and(s[i,j-1]<>-1) then s[i,j]:=s[i,j-1];
if (s[i,j]<>-1)and(s[i-1,j]<>-1)and(s[i,j-1]=-1) then s[i,j]:=s[i-1,j];
end;
writeln(f2,s[n,m]);
close(f2);
end.