結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
|
提出日時 | 2021-07-08 22:22:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,403 bytes |
コンパイル時間 | 1,286 ms |
コンパイル使用メモリ | 117,580 KB |
最終ジャッジ日時 | 2025-01-22 18:26:37 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 44 WA * 3 |
ソースコード
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <numeric> #include <optional> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { int32_t n; cin >> n; vector<int32_t> as(n); for (auto &&a : as) { cin >> a; } vector<vector<int32_t>> bmat(n, vector<int32_t>(n)); for (auto &&bs : bmat) { for (auto &&b : bs) { cin >> b; } } int64_t ans = 0, pat = 0; for (auto st = 0; st < (1 << n); ++st) { int64_t s = 0; for (auto i = 0; i < n; ++i) { if (!((st >> i) & 0b1)) continue; for (auto j = 0; j < n; ++j) { if (!((st >> j) & 0b1)) continue; s += bmat[i][j]; } } s /= 2; for (auto i = 0; i < n; ++i) { if ((st >> i) & 0b1) s += as[i]; } if (s > ans) { ans = s; pat = st; } } cout << ans << endl; bool first = true; for (auto i = 0; i < n; ++i) { if (!((pat >> i) & 0b1)) continue; cout << (first ? "" : " ") << i + 1; first = false; } cout << endl; return 0; }