結果

問題 No.1045 直方体大学
ユーザー micheeeeell1001micheeeeell1001
提出日時 2020-05-01 23:00:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,523 bytes
コンパイル時間 3,743 ms
コンパイル使用メモリ 244,388 KB
実行使用メモリ 98,048 KB
最終ジャッジ日時 2024-06-07 11:20:43
合計ジャッジ時間 13,831 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:67:5: warning: control reaches end of non-void function [-Wreturn-type]
   67 |     };
      |     ^

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

struct state{
    ll x,y,z;
    state(){}
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<state> v(n);
    rep(i,n)cin >> v[i].x >> v[i].y >> v[i].z;

    auto c = [&](ll j, ll k, ll l, ll m){
        ll one[2], two[2];
        if(k == 0){
            one[0] = v[j].x, one[1] = v[j].y;
        }
        if(k == 1){
            one[0] = v[j].z, one[1] = v[j].y;
        }
        if(k == 2){
            one[0] = v[j].x, one[1] = v[j].z;
        }
        if(m == 0){
            two[0] = v[l].x, two[1] = v[l].y;
        }
        if(m == 1){
            two[0] = v[l].z, two[1] = v[l].y;
        }
        if(m == 2){
            two[0] = v[l].x, two[1] = v[l].z;
        }
        if(one[0] >= two[0] && one[1] >= two[1])return true;
        if(one[0] >= two[1] && one[1] >= two[0])return true;
        return false;
    };
    auto f = [&](ll l, ll m){
        if(m == 0)return v[l].z;
        if(m == 1)return v[l].x;
        if(m == 2)return v[l].y;
    };
    vvvl dp(1 << n, vvl(n, vl(3)));
    rep(i,n){
        rep(j, 3)dp[1LL << i][i][j] = f(i, j);
    }
    rep(i, 1LL << n){
        rep(j,n){
            if((i >> j) & 1){

                rep(k, 3){
                    rep(l,n){
                        if((i >> l) & 1)continue;
                        rep(m,3){
                            if(c(j,k,l,m)){
                                chmax(dp[i | l][l][m], dp[i][j][k] + f(l,m));
                            }
                        }
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(i, 1LL << n){
        rep(j,n)rep(k,3)chmax(ans, dp[i][j][k]);
    }

    cout << ans << endl;
}
0