| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
1AC, 顶起PASCALvar i,j,k,l,m,n,x1,y1,x2,y2:longint;
a,short:array[0..101,0..101] of longint;
procedure dfs(x,y,t:longint);
begin
short[x,y]:=t;
if (x>1)and(a[x-1,y]<a[x,y])and(short[x-1,y]<t+1) then dfs(x-1,y,t+1);
if (x<n)and(a[x+1,y]<a[x,y])and(short[x+1,y]<t+1) then dfs(x+1,y,t+1);
if (y>1)and(a[x,y-1]<a[x,y])and(short[x,y-1]<t+1) then dfs(x,y-1,t+1);
if (y<m)and(a[x,y+1]<a[x,y])and(short[x,y+1]<t+1) then dfs(x,y+1,t+1);
end;
begin
read(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
fillchar(short,sizeof(short),0);
for i:=1 to n do
for j:=1 to m do
if (a[i,j]>=a[i-1,j])and(a[i,j]>=a[i+1,j])and(a[i,j]>=a[i,j-1])and(a[i,j]>=a[i,j+1]) then
dfs(i,j,0);
k:=0;
for i:=1 to n do
for j:=1 to m do if (short[i,j]>k) then k:=short[i,j];
writeln(k+1);
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator