結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-08 22:32:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 1,405 bytes |
| コンパイル時間 | 1,257 ms |
| コンパイル使用メモリ | 118,712 KB |
| 最終ジャッジ日時 | 2025-01-22 18:40:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#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 = -1, 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;
}