Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1AC, 顶起PASCAL

Posted by qiuwenhuah at 2012-08-24 09:28:16 on Problem 1088 and last updated at 2012-08-24 09:30:29
var 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator