#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vd = vector; using vvd = vector; using vs = vector; using pii = pair; using vpii = vector; using pil = pair; using vpil = vector; using pll = pair; using vpll = vector; using pdd = pair; using vpdd = vector; const int inf = (1 << 30) - 1; const ll INF = 1LL << 60; //const int MOD = 1000000007; const int MOD = 998244353; template inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); } int main() { int n; cin >> n; vvi f(n, vi(n, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int x; cin >> x; f[i][j] = f[j][i] = x; } } vl dp(1 << n, -1); dp[0] = 0; for (int b = 0; b < (1 << n) - 1; b++) { if (dp[b] == -1) continue; int x = -1; for (int i = 0; i < n; i++) { if ((b & (1 << i)) == 0) { x = i; break; } } for (int i = 0; i < n; i++) { if ((b & (1 << i)) == 0) { int to = b | (1 << x) | (1 << i); chmax(dp[to], dp[b] + f[x][i]); } } } cout << dp[(1 << n) - 1] << endl; return 0; }