結果
問題 |
No.519 アイドルユニット
|
ユーザー |
![]() |
提出日時 | 2025-03-17 20:50:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 995 bytes |
コンパイル時間 | 1,363 ms |
コンパイル使用メモリ | 160,320 KB |
実行使用メモリ | 149,044 KB |
最終ジャッジ日時 | 2025-03-17 20:51:01 |
合計ジャッジ時間 | 5,755 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 33 |
ソースコード
#include <bits/stdc++.h> #define int long long //#define USE_FREOPEN //#define MUL_TEST #define FILENAME "group" using namespace std; constexpr int MAXN = 24; int dp[(1 << MAXN) + 5],f[MAXN + 5][MAXN + 5]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> f[i][j]; } } memset(dp,-0x3f,sizeof(dp)); dp[0] = 0; for (int s = 0; s < (1 << n); s++) { if (dp[s] == -1) break; for (int i = 0; i < n; i++) if (((s >> i) & 1) == 0) { for (int j = 0; j < n; j++) { if (((s >> j) & 1) == 0) { int nxt = s ^ (1 << i) ^ (1 << j); dp[nxt] = max(dp[nxt],dp[s] + f[i][j]); } } } } cout << dp[(1 << n) - 1] << '\n'; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef USE_FREOPEN freopen(FILENAME ".in","r",stdin); freopen(FILENAME ".out","w",stdout); #endif int _ = 1; #ifdef MUL_TEST cin >> _; #endif while (_--) solve(); _^=_; return 0^_^0; }