結果
問題 |
No.519 アイドルユニット
|
ユーザー |
|
提出日時 | 2017-05-28 22:36:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 737 bytes |
コンパイル時間 | 1,580 ms |
コンパイル使用メモリ | 166,556 KB |
実行使用メモリ | 13,824 KB |
最終ジャッジ日時 | 2024-09-21 15:40:35 |
合計ジャッジ時間 | 5,960 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef array< array<bool, 24>, 24> Matrix; int n; int f[24][24]; int solve(int cur, Matrix used) { if (cur == n) return 0; int res = 0; for (int i = 0; i < n; i++) { if (i == cur || used[cur][i]) continue; Matrix nex(used); for (int j = 0; j < n; j++) { nex[cur][j] = true; nex[j][cur] = true; nex[i][j] = true; nex[j][i] = true; } res = max(res, solve(cur + 1, nex) + f[cur][i]); } if (res == 0) return solve(cur + 1, used); return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> f[i][j]; } } Matrix used{}; cout << solve(0, used) << endl; return 0; }