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

弱爆了弱爆了。。。

Posted by hncsyjc at 2013-03-23 21:26:02 on Problem 1088
水题。。。
贴代码贴代码~~~
const
        dx:array [1..4] of longint=(1,-1,0,0);
        dy:array [1..4] of longint=(0,0,1,-1);
var
        n,m,i,j,ans:longint;
        a,f:array [1..100,1..100] of longint;
        v:array [1..100,1..100] of boolean;
function max(a,b:longint):longint;
begin
        if a>b then exit(a);exit(b);
end;
function calc(x,y:longint):longint;
var
        i:longint;
begin
        if v[x,y] then exit(f[x,y]);
        v[x,y]:=true;
        calc:=0;
        for i:=1 to 4 do
          if (1<=x+dx[i])and(x+dx[i]<=n)and(1<=y+dy[i])and(y+dy[i]<=m)and(a[x+dx[i],y+dy[i]]<a[x,y])
          then calc:=max(calc,calc(x+dx[i],y+dy[i])+1);
        f[x,y]:=calc;
end;
begin
        readln(n,m);
        for i:=1 to n do
          for j:=1 to m do
            read(a[i,j]);
        for i:=1 to n do
          for j:=1 to m do
            ans:=max(ans,calc(i,j)+1);
        writeln(ans);
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