比赛 |
20120712 |
评测结果 |
AAAAAAAAAA |
题目名称 |
登山 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.082 s |
代码语言 |
Pascal |
内存使用 |
0.22 MiB |
提交时间 |
2012-07-12 10:10:26 |
显示代码纯文本
const
jx:array[1..4]of longint=(-1,0,1,0);
jy:array[1..4]of longint=(0,1,0,-1);
var
n,m,i,j,ans:longint;
a:array[0..100,0..100]of longint;
ch,v:array[0..100,0..100]of boolean;
procedure go(x,y,k,s:longint);
var
xx,yy,i:longint;
begin
if s>ans then ans:=s;
for i:=1 to 4 do
begin
xx:=x+jx[i];
yy:=y+jy[i];
if (ch[xx,yy])and(not v[xx,yy]) then
begin
v[xx,yy]:=true;
if k=1 then
begin
if a[xx,yy]>a[x,y] then go(xx,yy,1,s+1)
else if a[xx,yy]<a[x,y] then go(xx,yy,-1,s+1)
end
else begin
if a[xx,yy]<a[x,y] then go(xx,yy,-1,s+1);
end;
v[xx,yy]:=false;
end;
end;
end;
begin
assign(input,'hike.in'); reset(input);
assign(output,'hike.out'); rewrite(output);
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
ch[i,j]:=true;
for i:=1 to n do
for j:=1 to m do
begin
v[i,j]:=true;
go(i,j,1,1);
v[i,j]:=false;
end;
writeln(ans);
close(input);
close(output);
end.