- 清帝之惑之顺治
- 2015-01-30 13:58:39 @
排序后动规。。。只过了测试点#3#5#6#9。。。不知道为啥。。。能搞数据吗?
###Block code
const dx:array[1..4]of integer=(0,1,0,-1);
dy:array[1..4]of integer=(-1,0,1,0);
type xy=record
x,y:integer;
end;
var a:array[0..250001]of xy;
h:array[0..501,0..501]of integer;
l:array[0..501,0..501]of longint;
m,n,i,j,p,q:integer;
max,t:longint;
procedure qsort(l,r:longint);
var mid,i,j:longint;t:xy;
begin
i:=l;j:=r;mid:=h[a[(l+r)div 2].x,a[(l+r)div 2].y];
repeat
while h[a[i].x,a[i].y]<mid do
inc(i);
while h[a[j].x,a[j].y]>mid do
dec(j);
if i<=j then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
inc(i);dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(m,n);t:=0;
for i:=1 to m do
for j:=1 to n do
begin
read(h[i,j]);inc(t);
a[t].x:=i;a[t].y:=j;
l[i,j]:=1;
end;
qsort(1,t);
for i:=1 to t do
begin
p:=a[i].x;q:=a[i].y;
for j:=1 to 4 do
if (h[p,q]>h[p+dx[j],q+dy[j]]) then
if l[p+dx[j],q+dy[j]]+1>l[p,q] then
l[p,q]:=l[p+dx[j],q+dy[j]]+1;
end;
max:=0;
for i:=1 to m do
for j:=1 to n do
if l[i,j]>max then
max:=l[i,j];
write(max);
end.
2 条评论
-
doc LV 10 MOD @ 2015-01-31 11:47:17
你的程序第39行
for i:=1 to t do
其中t可能超过integer范围,所以你很明智地将t定义为longint,然而你定义的i依然是integer范围的,所以产生了错误。
-
2015-01-30 20:20:54@
他们数据弱?
- 1