这题是dp还是dfs+记忆化?(其实好像没什么区别?)
用f[i,j]表示滑到(i,j)时之后最多能滑多远,依次穷举每一个起点(i,j)则
f[i,j]=max{f[i,j-1],f[i-1,j],f[i+1,j],f[i,j+1]}+1 (当然滑到那个点的高度要小于(i,j)的高度)
const dx:array[..] of integer=(,,-,);
dy:array[..] of integer=(-,,,);
var f,a:array[..,..] of longint;
n,i,j,m,ans:longint;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;
procedure search(x,y:longint);
var i,xx,yy:integer;
maxx:longint;
begin
maxx:=;
for i:= to do
begin
xx:=x+dx[i];
yy:=y+dy[i];
if (a[xx,yy]<a[x,y]) and (f[xx,yy]=) then search(xx,yy);
if (a[xx,yy]<a[x,y]) then maxx:=max(maxx,f[xx,yy]);
end;
f[x,y]:=maxx+;
end; begin
readln(n,m);
for i:= to n+ do
for j:= to m+ do
a[i,j]:=;
for i:= to n do
begin
for j:= to m do
read(a[i,j]);
readln;
end;
for i:= to n do
for j:= to m do
if f[i,j]= then search(i,j);
for i:= to n do
for j:= to m do
ans:=max(ans,f[i,j]);
writeln(ans);
end.