#include #include int main() { int N; std::cin >> N; std::vector> F(N, std::vector(N)); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { std::cin >> F[i][j]; } } std::vector dp(1 << N, 0); for (int b = 0; b < (1 << N); b++) { if (__builtin_popcount(b) % 2 == 1) { continue; } for (int i = 0; i < N; i++) { if (b & (1 << i)) continue; for (int j = i + 1; j < N; j++) { if (b & (1 << j)) continue; int c = b | (1 << i) | (1 << j); dp[c] = std::max(dp[c], dp[b] + F[i][j]); } } } std::cout << dp[(1 << N) - 1] << std::endl; }