結果

問題 No.519 アイドルユニット
ユーザー vjudge1
提出日時 2025-03-15 13:08:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 775 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 160,944 KB
実行使用メモリ 61,752 KB
最終ジャッジ日時 2025-03-15 13:08:21
合計ジャッジ時間 6,398 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N = 24;
int n;
int a[N][N];
int f[1 << N];
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    f[0] = 0;
    for (int S = 1; S < (1 << n); S++)
    {
        if (__builtin_popcount(S) & 1)
            continue;
        for (int i = 0; i < n; i++)
            if ((S >> i) & 1)
                for (int j = i + 1; j < n; j++)
                    if ((S >> j) & 1)
                        f[S] = max(f[S], f[S ^ (1 << i) ^ (1 << j)] + a[i][j]);
    }
    cout << f[(1 << n) - 1] << endl;
    return 0;
}
0