firmanhp's blog

By firmanhp, history, 9 years ago, In English

Problem link (UVa 10901 — Ferry Loading III)

I got WA on this problem (if you're interested with my source code, here.)

After searching for some tricky cases, I found something that I don't understand.

1
4 3 3
76 left
83 left
97 left

and the expected output is: (udebug)

79
89
103

while my program outputs:

79
86
100

Which I think is the correct answer.

Explanation: The ferry waits on the left, until the first car arrives (time:76) and then it travels to the right side (the car arrives to destination at 76+3=79 ). Then, the ferry goes back to the left side (time:79+3=82) and waits until the second car arrives (time:83) and goes to the right side again ( time:83+3=86 ). Then, the ferry goes back to the left side again (time:86+3=89) and waited until (time:97) and goes to the right side ( time:97+3=100 )

The time for all cars to be unloaded is 79, 86, and 100 respectively.

Am I missing something important about the problem?

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

If there are no cars waiting on either bank, the ferry waits until one arrives, loads it (if it arrives on the same bank of the ferry), and crosses the river.

At time t=79 there are no cars on either bank. The ferry waits on the right bank until a car arrives at t=83. Then it crosses the river, loads it at t=86, crosses back and unloads at t=89.