求告诉程序错误原因

var
a,z:array[-2..1000,-2..1000]of longint;
n,m,x,y,o,p,i:longint;
begin
readln(n,m,x,y);
a[0,0]:=1;
z[1,1]:=x;
z[1,2]:=y;
z[2,1]:=x-1;
z[2,2]:=y-2;
z[3,1]:=x-2;
z[3,2]:=y-1;
z[4,1]:=x-2;
z[4,2]:=y+1;
z[5,1]:=x-1;
z[5,2]:=y+2;
z[6,1]:=x+1;
z[6,2]:=y+2;
z[7,1]:=x+2;
z[7,2]:=y+1;
z[8,1]:=x+2;
z[8,2]:=y-1;
z[9,1]:=x+1;
z[9,2]:=y-2;
for p:=0 to m do
for o:=0 to n do begin
a[0,0]:=1;
a[o,p]:=a[o-1,p]+a[o,p-1];
a[0,0]:=1;
for i:=1 to 9 do if (o=z[i,1])and(p=z[i,2])then a[o,p]:=0;
a[0,0]:=1;
end;
writeln(n,m);
end.

2 条评论

  • @ 2016-11-20 16:43:45

    棋盘型DP。
    const
    dx:array[1..9] of longint=(-2, -2, -1, 1, 2, 2, 1, -1, 0);
    dy:array[1..9] of longint=(-1, 1, 2, 2, 1, -1, -2, -2, 0);
    var
    map:array[-2..15, -2..15] of boolean;
    f:array[-1..15, -1..15] of longint;
    n, m, x, y, i, j:longint;
    begin
    read(n, m, x, y);
    fillchar(map, sizeof(map), true);
    fillchar(f, sizeof(f), 0);
    for i:=1 to 9 do map[x+dx[i], y+dy[i]]:=false;
    for i:=0 to n do
    for j:=0 to m do if map[i, j] then if (i=0) and (j=0) then f[i, j]:=1
    else f[i, j]:=f[i-1, j]+f[i, j-1];
    write(f[n, m])
    end.

  • @ 2013-03-15 21:46:11

    无论是x,还是y,都是有很多步,也就是有很多次变换的。在定义增量数组的时候,z[9,2]:=y-2;那些,不必把y写进去。z[9,2]:=-2;就好了

  • 1

信息

ID
1121
难度
4
分类
动态规划 点击显示
标签
递交数
9582
已通过
3785
通过率
40%
被复制
23
上传者