The question is as follow. (I've modified a little bit)
There's a bidirection graph reqresenting a road network. Each road has a length. And each vertex is a city.
A person wants to go from a source city to a destination city.
But he has limited full energy. For x amount of energy left of the person, he can only walk x length of the road.
There're also food stands at certain cities. At the food stand, he can regenerate to the full energy(lets say the full energy is defined as E).
So given E, source, destination, cities which has food stands, and the graph, I need to output whether the person can arrive the destination or not.
He has full energy initially.
Notice that a road (or an edge) can be passed unlimited times.
I've come up with an O(n^2) solution. (n is city count)
Are there any better solution?
Thanks.