#t519. 热浪
热浪
Heat Wave
Problem Background
Special for beginners, ^_^
Problem Description
The simple folk of Texas are suffering a huge heat wave this summer!!! Their Texas Longhorn cattle taste good, but they are not very good at producing dairy products rich in cream. Farmer John, with the spirit of worrying about the world before the world worries and enjoying the world after the world enjoys, takes the lead in taking on the important task of transporting large amounts of nutritious, cool milk from Wisconsin to Texas, to ease the pain of the Texans enduring the heat.
FJ has studied the routes that can transport milk from Wisconsin to Texas. These routes pass through () towns including the start and the end, conveniently numbered to . Every town other than the start and the end is connected to at least two other towns by two bidirectional roads. Each road has a passing cost (including fuel, tolls, etc.).
Given a map containing () roads directly connecting towns. Each road consists of its starting town , ending town (; ), and cost (). Find the minimum total cost from the starting town () to the ending town ().
Input Format
The first line: integers separated by spaces: .
Lines to : the -th line describes the -th road. It contains integers separated by spaces: and .
Output Format
A single integer representing the minimum total cost from to . The data guarantees that at least one road exists.
Sample Input
7 11 5 4
2 4 2
1 4 3
7 2 2
3 4 3
5 7 5
7 3 3
6 1 1
6 3 4
2 4 3
5 6 3
7 2 1
Sample Output
7
Constraints
Time limit: 1s; memory limit: 1024 KiB for each test case.