#P6822. [PA 2012 Finals] Tax
[PA 2012 Finals] Tax
Description
Given an undirected graph with vertices and edges, the cost of passing through a vertex is the larger of the weights of the two edges used to enter and leave this vertex. Find the minimum total cost from the start vertex to vertex . The cost at the start vertex is the weight of the edge leaving the start vertex, and the cost at the end vertex is the weight of the edge entering the end vertex.
Input Format
The first line contains two integers , representing the number of vertices and the number of edges.
The next lines each contain three integers , meaning there is an edge of length between and .
Output Format
Output one integer on a single line, representing the answer.
4 5
1 2 5
1 3 2
2 3 1
2 4 4
3 4 8
12
Hint
Constraints: ,,。
Translated by ChatGPT 5
京公网安备 11011102002149号