Time limit
0.5s
Memory limit
128 MB
There are N cities and M directed bus routes. Each bus route has a cost for traveling from one city to another.
Given a start city A and a destination city B, find the minimum total cost needed to travel from A to B. City numbers are from 1 to N.
The first line contains the number of cities N (1 <= N <= 1,000). The second line contains the number of bus routes M (1 <= M <= 100,000).
Each of the next M lines contains one bus route in the form start_city destination_city cost. The cost is an integer greater than or equal to 0 and less than 100,000.
The last line contains the start city and destination city for the query. The input is guaranteed to describe a case where the destination is reachable from the start city.
Print one line containing the minimum cost needed to travel from the start city to the destination city.