传说中的滑雪,巨丑勿拍(poj1088/tyvj1004)
作者:互联网
原文链接:http://www.cnblogs.com/lexluthor/archive/2011/10/14/2211220.html
const
wx:array[1..4]of longint=(1,-1,0,0);
wy:array[1..4]of longint=(0,0,1,-1);
var
ans,i,j,r,c:longint;
a,f:array[0..100,0..100]of longint;
visit:array[0..100,0..100]of boolean;
procedure dfs(x,y:longint);
var
nx,ny,i:longint;
begin
visit[x,y]:=true;
for i:=1 to 4 do
begin
nx:=x+wx[i];
ny:=y+wy[i];
if (nx>=1)and(ny>=1)and(nx<=c)and(ny<=r)and(a[nx,ny]<a[x,y])then
begin
if not visit[nx,ny]then dfs(nx,ny);
if (f[x,y]<f[nx,ny]+1)then f[x,y]:=f[nx,ny]+1;
end;
end;
end;
begin
fillchar(f,sizeof(f),false);
ans:=0;
readln(r,c);
for i:=1 to r do
for j:=1 to c do
begin
f[j,i]:=1;
read(a[j,i]);
end;
for i:=1 to r do
for j:=1 to c do
if not visit[j,i] then dfs(j,i);
for i:=1 to r do
for j:=1 to c do
if f[j,i]>ans then ans:=f[j,i];
writeln(ans);
end.
转载于:https://www.cnblogs.com/lexluthor/archive/2011/10/14/2211220.html
标签:巨丑,..,poj1088,nx,longint,ans,100,tyvj1004,array 来源: https://blog.csdn.net/weixin_30642869/article/details/98330145