#P10447. 最短 Hamilton 路径
最短 Hamilton 路径
Problem Description
Given a weighted undirected graph with vertices, numbered from to , find the shortest Hamilton path from the start vertex to the end vertex .
A Hamilton path here is defined as a path from to that visits every vertex exactly once, with no repeats and no omissions.
Input Format
The first line contains an integer .
The next lines each contain integers. The -th integer in the -th line represents the distance from vertex to vertex (denoted as ).
For any , the testdata guarantees that , , and .
Output Format
Output one integer, the length of the shortest Hamilton path.
5
0 2 4 5 1
2 0 6 5 3
4 6 0 8 3
5 5 8 0 5
1 3 3 5 0
18
Hint
Constraints: for all testdata, , and .
Translated by ChatGPT 5