• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 8. Dictionary

Difficulty level:

Task«Travel time»

💻 Python
You work in the logistics service of a large transport company. Your task & mdash; Find the shortest time route between the two cities using the available road network.
rn
you have information about the time of the neighboring cities in the form Lines of the "AB: 120" format, where AB means the road between cities A and B, and 120 & mdash; Travel time in minutes. Bilateral roads.
rn
it is necessary to find the minimum travel time to the final city using the shortest search algorithm Ways.

Input format

the first line contains the number of roads n. gap

Output format

the minimum travel time or "route is impossible" if there is no way

Example

Input

5
AB: 60
BC: 90
AC: 120
CD: 45
bd: 30
a d

Output

135

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!