PASCAL迷之80 2,6点WA

P1434 [SHOI2002] 滑雪

kingofpupil @ 2018-07-22 23:03:22

const dx:array[1..4] of integer=(0,0,-1,1); dy:array[1..4] of integer=(-1,1,0,0); var i,j,r,c,ans:longint; a:array[0..101,0..101] of longint; f:array[0..101,0..101] of longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; function fuck(x,y:longint):longint; var i,xx,yy,jl:longint; begin if f[x,y]<>0 then exit(f[x,y]); jl:=0; for i:=1 to 4 do begin xx:=x+dx[i]; yy:=y+dy[i]; if (xx>0)and(xx<=c)and(yy>0)and(yy<=r)and(a[xx,yy]<a[x,y]) then jl:=max(fuck(xx,yy),jl); end; f[x,y]:=max(jl+1,f[x,y]); exit(f[x,y]); end; begin readln(r,c); for i:=1 to c do begin for j:=1 to r do read(a[i,j]); readln; end; fillchar(f,sizeof(f),0); for i:=1 to c do for j:=1 to r do ans:=max(ans,fuck(i,j)); writeln(ans); end.


by kingofpupil @ 2018-07-22 23:04:05

求助硕佬


|