Tikki Trotter wants the cheapest tour that visits every numbered shrine exactly once and returns to shrine 1.
Input: n (1..15), then an n×n cost matrix; -1 means no direct road. Output minimum tour cost, or -1.
Example 1:
Input: 3
-1 1 5
2 -1 1
1 2 -1
Output: 3
Example 2:
Input: 2
-1 4
5 -1
Output: 9
Example 3:
Input: 3
-1 1 -1
-1 -1 1
1 -1 -1
Output: 3
Constraints:
2≤n≤15; costs 0..10^6.
Tags:
bitmask-dp traveling-salesperson
Loading...
Test Cases:No test cases
No test cases available.
Tikki Trotter’s Night Route - MEDIUM Coding Problem | CodeTikki