I got WA.....555555555.......Who can help me ?
Posted by
hello 11 May 2004 17:56
I got WA on test17. I can't find my mistakes....
I think the sample test is incorrect.
My solution got the answer is :
2 2 -1 2 -1
3 2 2 7 2
1 8 7 5 7
1 6 5 -1 5
-1 1 4 -1 4
But the sample output is :
2 2 -1 2 -1
3 2 2 7 2
1 7 7 5 7
1 5 5 -1 5
-1 1 4 -1 4
I think the sample output is wrong , isn't it ???
Is my answer right ?
Who can tell me ????
This is my code :
const
Maxn = 200 ;
var
h : Array [0..Maxn,0..Maxn] Of LongInt ;
cost : Array [0..Maxn,0..Maxn] Of Int64 ;
t : Array [0..6*Maxn] Of LongInt ;
n , m , i , j , k , len : Integer ;
Function check ( k : LongInt ) : Boolean ;
var
i : Integer ;
begin
check := false ;
if k = 0 then exit ;
for i := 1 to len do
if k = t[i] then exit ;
check := true ;
end;
procedure goin ( x , y , xi , yi : Integer ) ;
begin
if check ( h[xi,yi] ) then
begin
Inc ( cost[x,y] , h[xi,yi] ) ;
Inc ( len ) ;
t[len] := h[xi,yi] ;
end;
end;
procedure Bfs ( x , y , k : Integer ) ;
var
i , j , xi , yi : Integer ;
begin
len := 0 ;
for i := 1 to k - 1 do
begin
xi := x + i ;
if xi > n then break ;
if y + k - i <= m then goin ( x , y , xi , y + k - i ) ;
if y - k + i > 0 then goin ( x , y , xi , y - k + i ) ;
end;
for i := 1 to k - 1 do
begin
xi := x - i ;
if xi < 0 then break ;
if y + k - i <= m then goin ( x , y , xi , y + k - i ) ;
if y - k + i > 0 then goin ( x , y , xi , y - k + i ) ;
end;
if y + k <= m then goin ( x , y , x , y + k ) ;
if y - k > 0 then goin ( x , y , x , y - k ) ;
if x + k <= n then goin ( x , y , x + k , y ) ;
if x - k > 0 then goin ( x , y , x - k , y ) ;
end;
begin
read ( n , m ) ;
for i := 1 to n do
for j := 1 to m do
read ( h[i,j] ) ;
for i := 1 to n do
for j := 1 to m do
if h[i,j] = 0
then begin
for k := 1 to 5 do
begin
Bfs ( i , j , k ) ;
if len > 0 then break ;
end;
end
else cost[i,j] := -1 ;
for i := 1 to n do
begin
write ( cost[i,1] ) ;
for j := 2 to m do
write ( ' ' , cost[i,j] ) ;
writeln ;
end;
end.