結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
betit0919
|
| 提出日時 | 2021-01-22 21:30:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,576 bytes |
| コンパイル時間 | 2,126 ms |
| コンパイル使用メモリ | 128,184 KB |
| 最終ジャッジ日時 | 2025-01-18 03:45:49 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 44 RE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:74:17: warning: ‘ans_mask’ may be used uninitialized [-Wmaybe-uninitialized]
74 | if(ans_mask & (1 << i))
| ~~~~~~~~~^~~~~~~~~~
main.cpp:54:16: note: ‘ans_mask’ was declared here
54 | ll ans = -1, ans_mask;
| ^~~~~~~~
ソースコード
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
template <class T> inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<ll> A(N);
vector<vector<ll>> B(N, vector<ll>(N));
REP(i, N) { cin >> A[i]; }
REP(i, N) {
REP(j, N) { cin >> B[i][j]; }
}
ll ans = -1, ans_mask;
REP(mask, 1 << N) {
ll sum = 0;
REP(i, N) {
if(mask & (1 << i))
sum += A[i];
}
REP(i, N) {
REP(j, i) {
if((mask & (1 << i)) && (mask & (1 << j)))
sum += B[i][j];
}
}
if(chmax(ans, sum)) {
ans_mask = mask;
}
}
cout << ans << endl;
vector<int> anss;
REP(i, N) {
if(ans_mask & (1 << i))
anss.push_back(i + 1);
}
REP(i, anss.size() - 1) { cout << anss[i] << " "; }
cout << anss[anss.size() - 1] << endl;
}
betit0919