#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int dp[1 << 24]; int main() { int N; cin >> N; int V[N][N]; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { cin >> V[i][j]; } } int L = 1 << N; memset(dp, 0, sizeof(dp)); int ans = 0; for (int mask = 0; mask < L; ++mask) { ans = max(ans, dp[mask]); if (__builtin_popcount(mask) & 1) continue; for (int j = 0; j < N; ++j) { if (mask >> j & 1) continue; for (int k = j + 1; k < N; ++k) { if (mask >> k & 1) continue; int nmask = mask | (1 << j) | (1 << k); dp[nmask] = max(dp[nmask], dp[mask] + V[j][k]); } break; } } cout << ans << endl; return 0; }