| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WHO CAN TELL MW WHAT THE WRONG IS!!!!!(THANKS A LOT)program skiing;
const fx:array[1..4,1..2] of integer=((0,1),(1,0),(0,-1),(-1,0));
var a:array[1..10000,1..4] of longint;
te,i,j,m,n,q,p,max,max2:longint;
judge:boolean;
procedure qsort(l,r:longint);
var
i,j,mid,t:longint;
begin
i:=l;j:=r;mid:=a[(l+r)shr 1,1];
repeat
while a[i,1]<mid do inc(i);
while a[j,1]>mid do dec(j);
if i<=j then
begin
t:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t;
t:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t;
t:=a[i,3];a[i,3]:=a[j,3];a[j,3]:=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
fillchar(a,sizeof(a),0);
read(m,n);
for i:=1 to m do
begin
for j:=1 to n do
begin
q:=q+1;
read(a[q,1]);
a[q,2]:=i;
a[q,3]:=j;
a[q,4]:=1;
end;
readln;
end;
for i:=1 to q do qsort(1,i);
for i:=q-1 downto 1 do
begin
for j:=i+1 to q do
begin
judge:=false;
for te:=1 to 4 do
begin
m:=fx[te,1]+a[i,2];
n:=fx[te,2]+a[i,3];
if (m=a[j,2])and(n=a[j,3])and(a[j,4]>max) then
begin
judge:=true;
max:=a[j,4];
end;
end;
if judge then
a[i,4]:=max+a[i,4];
if a[i,4]>max2 then max2:=a[i,4];
end;
end;
write(max2);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator