Travelling Salesman Problem 3 - MarisaOJ: Marisa Online Judge

Travelling Salesman Problem 3

Time limit: 3000 ms
Memory limit: 256 MB
There are $n$ cities. Going from city $i$ to city $j$ cost $A_{i, j}$ coins. Find the minimum cost route that visits each city exactly once and returns to the starting city. ### Input - The first line contains integers $n$. - Next $n$ lines, $i^{th}$ line contains $n$ integers $A_{i, j}$. ### Output - The first line contains a single integers is the minimum cost. - The second line contains $n$ integers, denoting the journey. ### Constraints - $1 \le n \le 100$ - $1 \le A_{i, j} \le 10^5$ ### Example Input: ``` 5 0 2 8 5 1 10 0 5 9 9 3 5 0 6 6 2 8 2 0 2 6 3 8 7 0 ``` Output: ``` 17 3 4 1 5 2 ``` ### Scoring - All test cases are scored equally. - Consider the jury's answer as $Y$ and your answer as $X$. - If $X$ is less than or equal to $Y$, you receive a score of $100\\%$ for test case. - If $1 < \frac{X}{Y} \le 2$, your score for the test case is calculated as $\frac{2Y - X}{Y}\times 100 \\%$. - If $\frac{X}{Y} > 2$, you receive a score of $0\\%$ for the test case.