~/algor $ cat problems/bit-shaharlarni-aylanish
Visiting all cities
Hard
2000 ms
128 MB
67%
There are $n$ cities, travelling from city $i$ to city $j$ costs $d_{i,j}$ (the cost may depend on the direction, $d_{i,i} = 0$). A traveller leaves city $1$, must visit every other city exactly once and return to city $1$. Find the smallest total cost. If $n = 1$, the answer is $0$.
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains $n$ integers — $d_{i,j}$.
Output
One integer — the smallest cost.
Note
$1 \le n \le 12$
$0 \le d_{i,j} \le 10^{6}$, $d_{i,i} = 0$
Examples
Input #1
4 0 10 15 20 5 0 9 10 6 13 0 12 8 8 9 0
Output #1
35
Input #2
1 0
Output #2
0