Design O(n^2*2^n) DP for TSP using bitmask

You are given a complete directed graph with n cities, represented by an n x n matrix dist, where dist[i][j] is the non-negative cost of traveling directly from city i to city j. The tour starts at city 0, visits every other city exactly once, and returns to city 0. Return the minimum tour cost.

The functional input is a newline-delimited encoding: the first line contains n, followed by n lines containing n integer weights separated by spaces. The matrix diagonal may be zero. The implementation must solve arbitrary supported matrices, not a fixed example or a fixed city count.

Examples
Input: "4\n0 10 15 20\n10 0 35 25\n15 35 0 30\n20 25 30 0"
Output: 80
Hints

Design O(n^2*2^n) DP for TSP using bitmask

You are given a complete directed graph with `n` cities, represented by an `n x n` matrix `dist`, where `dist[i][j]` is the non-negative cost of traveling directly from city `i` to city `j`. The tour starts at city `0`, visits every other city exactly once, and returns to city `0`. Return the minimum tour cost.