#P1171. 售货员的难题

售货员的难题

Description

In a certain township, there are nn villages. A salesman needs to visit each village to sell goods. The distances si,js_{i,j} between villages are known, and, in general, the road from village A to village B may be different from the road from village B to village A. To improve efficiency, he starts from the store, visits each village exactly once, and then returns to the village where the store is located. Assume the store is in village 11. He does not know which route will minimize the total distance traveled. Please help him choose a route with the shortest total length.

Input Format

The first line contains an integer nn, the number of villages.
The next nn lines each contain nn integers. In the ii-th line, the jj-th integer represents the distance si,js_{i,j} of the one-way path from ii to jj.

Output Format

Output a single integer on one line, representing the length of the shortest route.

3
0 2 1
1 0 2
2 1 0
3

Hint

For all testdata, it is guaranteed that 2n202 \leq n \leq 20, 1si,j<1031 \leq s_{i,j} < 10^3.

Translated by ChatGPT 5