intmain() { fill(dp[0], dp[0] + M * N, 0x3f3f3f3f); dp[1][0] = 0; // initial_data
cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> g[i][j]; } } // read graph
for (int i = 0; i < (1 << n); ++i) // for each status i { for (int j = 0; j < n; ++j) { if (i >> j & 1) // arrived j { for (int k = 0; k < n; ++k) { if ((i - (1 << j)) >> k & 1) // arrived k but not arrived j { dp[i][j] = min(dp[i][j], dp[i - (1 << j)][k] + g[j][k]); } } } } }