kelvin's blog

By kelvin, 12 years ago, In English

Hi, I didn't particicpate in this contest (#148 div.1) due to the need to prepare for the exam. Later today I came back to browse the problems and think about them.

I think problem E in this contest is wrong (will elaborate below), or at least, as far as the official solution (and the solution i come up with at first) concerns. The major problem is that, given the rules, there are in fact more information than could be acquired when Urpal "misses" a bus. This results in means to "forcely" get on a bus, even on some of the node the bus "does not necessarily" has to go through.

Easier illustrated than described, consider the following case:

8 9 2 8
1 3
3 6
1 7
7 4
4 8
6 8
2 3
3 4
4 5
2
1 8
2 5

The ASCII plot of this graph:

5   8
 \ / \
  4   6
  |\_ |
  |  \|
  7   3
   \ / \
    1   2

The output according to editorial's solution (and my Accepted solution):

-1

The actual solution:

2

In this case Upral starts from "2" and is going to cross the "bus route" of bus 1: 1->8. In the author's sense, when Upral takes the bus and reaches node 3, bus 1 may not be there, and he has no oppurtunity to switch route. Then again at node 4, Upral again misses bus 1 (an adversary bus 1 driver!) thus he is stuck with bus 2.

But what actually happens (if Upral is as smart as anyone on Codeforces!), is that when he takes bus 2 and get to node 3, but does not see bus 1, it actually implies that at this time bus 1 must be at node 7 (recall that each second a bus spawn from its source), and on the next time fragment when Upral gets to node 4, that bus 1 he just missed at node 3 HAS to be there as well. Therefore in this case, Upral can in fact always get to node 8, and the answer should be 2 in this sense.

I understand what the problemsetter is trying to formulate in this problem, and if nothing could be implied by "missing a bus", the solution would be perfect. But I think the assumption cannot hold under the rules, and the original solution could not handle this. (Neither could I think of any revision from the original one that handle this, though. My instinct tells me with this kind of inference, it may be too hard a problem to solve efficiently.)

A possible argument is that "when Upral is on a bus, he could not know whether another bus is at the same node UNLESS he gets off the bus; this way he won't be able to infer anything UNLESS he gets off the current bus he's on". But this does not sort out the problem either. Upral could still get off the bus and observe (wait for one second) then act accordingly.

I took noticed of this case when I was testing my solution (which operates just about the same as the author's). I hope I did not get something wrong. If there's any mistake, please kindly point it out >"<.

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

»
12 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Probably author means, that we can go throw edge for very long time, and this time is undefined. So we can miss bus from 7. But formally nothing said about it.

  • »
    »
    12 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You make really good point! Ouch I really haven't thought of that. It'd make perfect sense then. Thanks for pointing this out.

  • »
    »
    12 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    "At the beginning of every second, a bus from the i-th company chooses a random shortest path between junction si and junction ti and passes through it"

    I think this part of statement contradicts this assumption.

  • »
    »
    12 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    If the rules clearly state what PavelKunyavskiy proposed, one cannot infer anything from "not seeing a bus coming", as the arrival time is not fixed, and there's no way to infer in finite time if a bus that did not show up simply "hasn't arrive" or "took another route". And when one decide to move for ex, from node 3 to 4 in the example, it is always possible to miss the bus assuming "adversary bus planning". The fact that "the bus spawn every one second" only helps to ensure the buses will continuously take off, but makes no guarantee about how soon it will arrive (except in "finite time", of course). This way my original claim won't work anymore, and I believe the original solution would then be flawless.

    Therefore I think the explanation of PavelKunyavskiy is just what this problem need to perfect it's statement.

»
12 years ago, # |
  Vote: I like it +5 Vote: I do not like it

By the way, I would want to add that, even though I find the original solution a bit "buggy" due to the reasons I mentioned, I really like this problem. It would be a really great problem if this small issue is fixed (from the statement I mean, since I truly doubt the "real" version with the "miss-a-bus inference" is easily solvable)!

»
12 years ago, # |
Rev. 2   Vote: I like it +16 Vote: I do not like it

It seems that the statement is a little bit misleading. The point is that we don't have any information about the velocity of the buses. As PavelKunyavskiy has said it might take different amount of time for different buses to pass an edge.

I'm sorry for the misunderstanding, the statement will now mention this. :)