Re: Got WrongAnswer at #6
i too got WA6, any corner case which we are missing?
Re: Got WrongAnswer at #6
I've got WA 6. What's wrong in my program?
Var
fee,r:array[1..500,1..100] of qword;
dir:array[1..500,1..100] of (DUp,DLeft,DRight);
floor,floors,room,rooms,minroom:integer;
Begin
{$IFNDEF ONLINE_JUDGE}
assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);
{$ENDIF}
readln(floors,rooms);
for floor:=1 to floors do begin
for room:=1 to rooms do
read(fee[floor,room]);
readln;
end;
for room:=1 to rooms do
r[floors,room]:=fee[floors,room];
for floor:=floors-1 downto 1 do begin
{primary fill}
for room:=1 to rooms do begin
r[floor,room]:=fee[floor,room]+r[floor+1,room];
dir[floor,room]:=DUp;
end;
{form left to right}
for room:=2 to rooms do
if fee[floor,room]+r[floor,room-1] < r[floor,room] then begin
r[floor,room]:=fee[floor,room]+r[floor,room-1];
dir[floor,room]:=DLeft;
end;
{from right to left}
for room:=rooms-1 downto 1 do
if fee[floor,room]+r[floor,room+1] < r[floor,room] then begin
r[floor,room]:=fee[floor,room]+r[floor,room+1];
dir[floor,room]:=DRight;
end;
end;
minroom:=1;
for room:=2 to rooms do
if r[1,room] < r[1,minroom] then minroom:=room;
room:=minroom;
floor:=1;
write(room,' ');
while floor<floors do begin
case dir[floor,room] of
DUp:Inc(floor);
DLeft:Dec(room);
DRight:Inc(Room);
end;
write(room,' ');
end;
{$IFNDEF ONLINE_JUDGE}
close(input);
close(output);
{$ENDIF}
end.