結果

問題 No.1045 直方体大学
ユーザー 259_Momone259_Momone
提出日時 2020-05-01 22:16:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,761 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 217,408 KB
実行使用メモリ 25,168 KB
最終ジャッジ日時 2023-08-26 14:39:12
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<pair<unsigned long, unsigned long>, unsigned long>> r(N);
    for(auto&& i : r){
        vector v{0, 0, 0};
        cin >> v[0] >> v[1] >> v[2];
        sort(v.begin(), v.end());
        i.first.first = v[0];
        i.first.second = v[1];
        i.second = v[2];
    }
    unsigned long ans{0};
    vector<unordered_map<unsigned long, unsigned long>> dp(1UL << N);
    for(unsigned long i{0}; i < N; ++i){
        ans = max(ans, r[i].second);
        dp[1UL << i].emplace((r[i].first.first << 20) + r[i].first.second, r[i].second);
        dp[1UL << i].emplace((r[i].first.first << 20) + r[i].second, r[i].first.second);
        dp[1UL << i].emplace((r[i].first.second << 20) + r[i].second, r[i].first.first);
    }
    for(unsigned long j{1}; j < 1UL << N; ++j)for(const auto& [s, h] : dp[j])for(unsigned long i{0}; i < N; ++i)if(~(j >> i) & 1){
        unsigned long c{1UL << i};
        const auto& [x, y] = make_pair(s >> 20, s & 1048575);
        if(r[i].first.first > x || r[i].first.second > y)continue;
        dp[j | (1UL << i)][(r[i].first.first << 20) + r[i].first.second] = max(dp[j | (1UL << i)][(r[i].first.first << 20) + r[i].first.second], ans = max(ans, h + r[i].second));
        if(r[i].second > y)continue;
        dp[j | (1UL << i)][(r[i].first.first << 20) + r[i].second] = max(dp[j | (1UL << i)][(r[i].first.first << 20) + r[i].second], ans = max(ans, h + r[i].first.second));
        if(r[i].first.second <= y)dp[j | (1UL << i)][(r[i].first.second << 20) + r[i].second] = max(dp[j | (1UL << i)][(r[i].first.second << 20) + r[i].second], ans = max(ans, h + r[i].first.first));
    }
    cout << ans << endl;
    return 0;
}
0