BMI博士想要拜訪N個城市,且博士希望能遵守三個原則:

城市拜訪

BMI博士想要拜訪N個城市,且博士希望能遵守三個原則:

  1. 每一座城市都要拜訪到
  2. 可以從任意城市出發,但最終要回到出發的城市
  3. 除了最終回到出發城市之外,不能拜訪已經訪問過的城市 (每座城市只能拜訪一次)

img


Sample Input 1:
4
0 3 7 8
3 0 2 6
7 2 0 4
8 6 4 0

Sample Output 1:
17


Sample Input 2:
3
0 3 7
3 0 2
7 2 0

Sample Output 2:
12


Sample Input 3:
4
0 10 15 20
10 0 35 25
15 35 0 30
20 25 30 0

Sample Output 3:
80


Sample Input 4:
5
0 1 4 5 3
1 0 2 3 4
2 3 0 3 4
3 2 1 0 3
9 1 2 3 0

Sample Output 4:
10


Sample Input 5:
5
0 3 4 2 6
5 0 3 5 1
8 5 0 6 9
5 3 9 0 5
9 8 6 4 0

Sample Output 5:
19

求解答