結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2021-01-22 21:59:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,516 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 89,532 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-27 18:56:26
合計ジャッジ時間 8,314 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 75 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 75 ms
4,376 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 10 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 75 ms
4,380 KB
testcase_34 AC 75 ms
4,380 KB
testcase_35 AC 75 ms
4,376 KB
testcase_36 AC 75 ms
4,376 KB
testcase_37 AC 76 ms
4,380 KB
testcase_38 AC 75 ms
4,380 KB
testcase_39 AC 75 ms
4,376 KB
testcase_40 AC 75 ms
4,380 KB
testcase_41 AC 75 ms
4,380 KB
testcase_42 AC 75 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
#include<algorithm>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = size_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using ld = long double;
template<typename T>
using vec = vector<T>;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define len(hoge) (i64)((hoge).size())
using P = pair<i64,i64>;
void solve(){
}
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    cin >> n;
    vec<i64> a(n);
    vec<vec<i64>> b(n,vec<i64>(n));
    rep(i,n)cin >> a[i];
    rep(i,n){
        rep(j,n)cin >> b[i][j];
    }
    i64 ans = -1;
    vec<i64> list;
    rep(bit,(1 << n)){
        vec<i64> rec;
        i64 tmp = 0;
        rep(i,n){
            if(bit & (1 << i)){
                rec.emplace_back(i);
                tmp += a[i];
            }
        }
        rep(i,n){
            for(i32 j = i + 1; j < len(rec);j++){
                tmp += b[rec[i]][rec[j]];
            }
        }
        if(ans < tmp){
            ans = tmp;
            list = rec;
        }
    }
    cout << ans << endl;
    rep(i,len(list)){
        cout << list[i] + 1 << " \n"[i == len(list) - 1];
    }
}
0