得分: 90分
提交日期: 2008-9-25 20:32:00
有效耗时: 734毫秒
测试结果1: 通过本测试点|有效耗时171:ms
测试结果2: 通过本测试点|有效耗时63:ms
测试结果3: 通过本测试点|有效耗时47:ms
测试结果4: 通过本测试点|有效耗时62:ms
测试结果5: 通过本测试点|有效耗时47:ms
测试结果6: 通过本测试点|有效耗时47:ms
测试结果7: 通过本测试点|有效耗时47:ms
测试结果8: 通过本测试点|有效耗时63:ms
测试结果9: 测试结果错误.错误结果为:12
正确结果应为:10
测试结果10: 通过本测试点|有效耗时187:ms
const
g:array[1..4,1..2]of integer=((1,0),(-1,0),(0,1),(0,-1));
var
f:array[0..500,0..500]of boolean;
h,a:array[0..500,0..500]of longint;
i,j,k,t,max,m,n:integer;
function fun(l1,l2:integer):integer;
var i,t:integer;
begin
if l1*l2<=0 then
fun:=-1;
if not f[l1,l2] then
begin
fun:=h[l1,l2];
exit;
end;
for i:= 1 to 4 do
if a[l1,l2]<a[l1+g[i,1],l2+g[i,2]] then
begin
t:=fun(l1+g[i,1],l2+g[i,2])+1;
if t>h[l1,l2] then
h[l1,l2]:=t;
end;
f[l1,l2]:=false;
fun:=h[l1,l2];
end;
begin
read(n,m);
for i:= 1 to n do
for j:= 1to m do
begin
read(a[i,j]);
end;
fillchar(f,sizeof(f),true);
for i:= 1 to n do
for j:= 1to m do
if f[i,j] then
begin
for k:= 1to 4 do
begin
if a[i,j]<a[i+g[k,1],j+g[k,2]] then
begin
t:=fun(i+g[k,1],j+g[k,2])+1;
end;
if t>h[i,j] then
h[i,j]:=t;
end;
f[i,j]:=false;
end;
for I:= 1to n do
for j:= 1to m do
begin
if max<h[i,j] then
max:=h[i,j];
end;
write(max+1);
end.