传说中的滑雪,巨丑勿拍(poj1088/tyvj1004)
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.
posted on 2011-10-14 10:20 Lex Luthor 阅读(177) 评论(0) 编辑 收藏 举报