Fast and cheap X66804


Statement
 

pdf   zip

html

Input

The input to your program will consist of one data set of in the following format:

  1. A floating point number that indicates the fuel efficiency in miles per gallon.
  2. A floating point number that indicates the gas cost in dollars per gallon.
  3. An integer N that indicates the number of cities in the system, followed by the N names of the cities placed in a different line each.
  4. An integer M that indicates the number of roads in the system follow by M road definitions containing 5 items:
    1. The road city of origin as string.
    2. The road city of destination as a string.
    3. The road name as a string.
    4. The road mileage as a floating point number.
    5. The road toll as a floating point number.
  5. An integer T that indicates the number of trips to compute, followed by the T names of the origin and destination cities placed in a different line each.

Output

  1. The total trip cost in dollars and the total mileage travelled using a precision of 2 decimals.
  2. The roads visited during the trip containing:
    1. The road name.
    2. The road mileage using a precision of 2 decimals.
    3. The road segment cost in dollars using a precision of 2 decimals.
    4. The city of origin.
    5. The city of destination.
Public test cases
  • Input

    25.0
    2.0
    6
    Eureka
    Sacramento
    SF
    SantaFe
    Fresno
    LA
    8
    Eureka Sacramento US-101 288.0 0.0
    Eureka SF US-101 271.0 20.0
    Sacramento SantaFe I-40 1142.0 0.0
    SF SantaFe I-40 1146.0 0.0
    SF LA I-5 381.0 50.0
    SF Fresno CA-99 187.0 0.0
    Fresno LA CA-99 220.0 0.0
    LA SantaFe I-40 874.0 0.0
    3
    Eureka LA
    Eureka SF
    Fresno SantaFe
    

    Output

    74.24 678.00
    US-101 271.00 41.68 Eureka SF
    CA-99 187.00 14.96 SF Fresno
    CA-99 220.00 17.60 Fresno LA
    41.68 271.00
    US-101 271.00 41.68 Eureka SF
    87.52 1094.00
    CA-99 220.00 17.60 Fresno LA
    I-40 874.00 69.92 LA SantaFe
    
  • Information
    Author
    HP CodeWars
    Language
    English
    Official solutions
    C++
    User solutions
    Python