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 |
帮我优化一下var hill,a,b:array[0..101,0..101]of longint; i,j,x,y,s,max:longint; begin read(x,y); for i:=1 to x do for j:=1 to y do read(hill[i,j]); fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); for i:=1 to x do for j:=1 to y do a[i,j]:=1; for s:=2 to x*y do begin for i:=1 to x do for j:=1 to y do begin b:=a; if hill[i,j]<hill[i+1,j] then begin if b[i,j]<=a[i+1,j] then b[i,j]:=a[i+1,j]+1;end; if hill[i,j]<hill[i,j+1] then begin if b[i,j]<=a[i,j+1] then b[i,j]:=a[i,j+1]+1;end; if hill[i,j]<hill[i-1,j] then begin if b[i,j]<=a[i-1,j] then b[i,j]:=a[i-1,j]+1;end; if hill[i,j]<hill[i,j-1] then begin if b[i,j]<=a[i,j-1] then b[i,j]:=a[i,j-1]+1;end; a:=b; end; end; max:=0; for i:=1 to x do for j:=1 to y do if a[i,j]>max then max:=a[i,j]; writeln(max); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator