ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN303 2013-15 Questions > задача:


50464 - From Tirana to Durres

CEN303 2013-15 Questions

Старт: 15.дек.2013 в 14:00:00
Финиш: 15.дек.2013 в 19:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 50472 - Minimum Sum Triangle
• 50842 - Minimum Sum Triangle - DP
• 50319 - Toll Plazas
• 51000 - Book Index
• 50531 - File Decryption
• 50464 - From Tirana to Durres
• 13-Fall2-10. 50411 - Sum of the Lea...
• 13-Fall2-20. 50687 - Pascal Triangle - 2
• 13-Fall2-40. 50753 - Average of the...
• 13-Fall2-50. 50686 - The Container
• 14-Fall1-10. 50740 - Service Time - 1
• 14-Fall1-20. 50750 - Service Time - 2
• 14-Fall1-30. 50771 - BST Level Sum
• 14-Fall1-40. 50683 - Te Parkojme A...

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

From Tirana to Durres

Question:
Write a program that finds the shortest path between any two given cities in a directed graph G.

Input specification
The first line contains a number (E) which represents the number of edges Then in the following E lines, it writes the name of two cities (city1 and city2) and an integer number d which means there is a path from the first city (city1) to the second one (city2) with the given distance (d).

At the last line of the input, you will be given the names of two cities (srcCity, destCity). You will find the shortest path from the srcCity to destCity (, if there is any) where 1 ≤ n ≤ 60

Output specification
Show the distance between city1 and city2 if there exists a path. If there is no path show -1.

Sample Input I   
12
Tirana Elbasan 2
Tirana Vlora 4
Tirana Peshkopia 1
Elbasan Peshkopia 3
Elbasan Fier 10
Vlora Durres 5
Peshkopia Vlora 2
Peshkopia Durres 8
Peshkopia Kavaja 4
Fier Peshkopia 2
Fier Kavaja 6
Kavaja Durres 1
Tirana Durres

Sample Output I   
6


Для отправки решений необходимо выполнить вход.

www.contester.ru