ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1029. Ministry

Got WrongAnswer at #6
Posted by James Xie 11 Apr 2008 10:33
if you have got WA at #6,you could Answer me
Re: Got WrongAnswer at #6
Posted by simon 11 Jul 2008 19:27
I have the same problem
Re: Got WrongAnswer at #6
Posted by Madhan G 28 Jul 2008 15:33
i too got WA6, any corner case which we are missing?
Re: Got WrongAnswer at #6
Posted by ZeleninAA 10 Apr 2009 16:35
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.
Re: Got WrongAnswer at #6
Posted by remdy21 3 Aug 2009 12:22
I also WA6