結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
![]() |
提出日時 | 2023-07-27 23:09:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 1,266 bytes |
コンパイル時間 | 3,791 ms |
コンパイル使用メモリ | 254,180 KB |
最終ジャッジ日時 | 2025-02-15 19:37:58 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:62:19: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 62 | if (two[i]&x) main.cpp:32:8: note: ‘x’ was declared here 32 | ll x; | ^
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;using ll=long long;using ld=long double;ld pie=3.141592653589793;ll mod=998244353 ;ll inf=10000999999999900;int main(){ll n;cin >> n;vector<ll>a(n);for (ll i = 0; i < n; i++){cin >> a[i];}vector<vector<ll>>b(n,vector<ll>(n));for (ll i = 0; i < n; i++){for (ll j = 0; j < n; j++){cin >> b[i][j];}}vector<ll>two(30,1);for (ll i = 1; i < 30; i++){two[i]=two[i-1]*2;}ll ans=-inf;ll x;for (ll i = 1; i < two[n]; i++){ll y=0;for (ll j = 0; j < n; j++){if (two[j]&i){y+=a[j];}}for (ll j = 0; j < n; j++){for (ll k = j+1; k < n; k++){if (two[j]&i&&two[k]&i){y+=b[j][k];}}}if (y>ans){ans=y;x=i;}}cout << ans << endl;for (ll i = 0; i < n; i++){if (two[i]&x){cout << i+1 << ' ';}}}