70 Points

A Star In The Universe

You've been recently appointed by NASA to investigate the feasibilty of space exploration by powering space ships with the light and heat from stars. To do this, space ships will need to pass stars very closely to collect power from the star.

Unfortunately you may not travel between all stars, since black holes are all around the universe. For this reason, we will provide you with a data set containing all the stars and weights connecting them. You can assume connections are bi-directional.

Additionally, when travelling between stars, you consume an amount of fuel. Without fuel, you cannot continue your mission.

The first star in the input set is your starting position. The second star in the input set is your goal position. The fuel given for the first star is your starting fuel level. Your task is to determine:

  • Whether you can reach the goal star without running out of fuel.
  • The minimal distance to reach the goal star without running out of fuel.
  • Fuel burnt reaching the goal.

Sample Input

# Star <name> <fuel gained>
Star Eridanus 100
Star Leo 0
Star Andromeda 60
Star Lyra 20
# Flight <start> <end> <distance> <fuel consumed>
Flight Eridanus Leo 1000 58
Flight Lyra Leo 856 70

Sample Output

Reachable: Yes
Distance: 1000
Fuel Burnt: 58