結果
問題 | No.1045 直方体大学 |
ユーザー | polylogK |
提出日時 | 2020-05-01 22:06:16 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 708 ms / 2,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 2,187 ms |
コンパイル使用メモリ | 205,768 KB |
実行使用メモリ | 63,084 KB |
最終ジャッジ日時 | 2023-08-26 13:53:12 |
合計ジャッジ時間 | 9,195 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 6 ms
4,376 KB |
testcase_06 | AC | 6 ms
4,392 KB |
testcase_07 | AC | 5 ms
4,380 KB |
testcase_08 | AC | 612 ms
63,024 KB |
testcase_09 | AC | 632 ms
63,032 KB |
testcase_10 | AC | 628 ms
63,084 KB |
testcase_11 | AC | 614 ms
63,012 KB |
testcase_12 | AC | 607 ms
63,080 KB |
testcase_13 | AC | 614 ms
63,032 KB |
testcase_14 | AC | 602 ms
63,072 KB |
testcase_15 | AC | 633 ms
62,940 KB |
testcase_16 | AC | 620 ms
62,896 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 708 ms
62,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);} template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); } int main() { int n; scanf("%d", &n); auto a = make_v<int>(3, n); for(int i = 0; i < n; i++) scanf("%d%d%d", &a[0][i], &a[1][i], &a[2][i]); int ans = 0; auto dp = make_v<int>(1 << n, n, 6); std::vector<int> A = {0, 0, 1, 1, 2, 2}; std::vector<int> B = {1, 2, 0, 2, 0, 1}; std::vector<int> C = {2, 1, 2, 0, 1, 0}; for(int j = 0; j < n; j++) { for(int k = 0; k < 6; k++) { int x = a[A[k]][j], y = a[B[k]][j], z = a[C[k]][j]; dp[1 << j][j][k] = z; ans = std::max(ans, z); } } for(int i = 0; i < (1 << n); i++) { for(int j = 0; j < n; j++) { if(!(i >> j & 1)) continue; for(int k = 0; k < 6; k++) { int x = a[A[k]][j], y = a[B[k]][j], z = a[C[k]][j]; for(int l = 0; l < n; l++) { if(i >> l & 1) continue; for(int K = 0; K < 6; K++) { int X = a[A[K]][l], Y = a[B[K]][l], Z = a[C[K]][l]; if(x < X or y < Y) continue; dp[i | (1 << l)][l][K] = std::max(dp[i | (1 << l)][l][K], dp[i][j][k] + Z); ans = std::max(ans, dp[i | (1 << l)][l][K]); } } } } } printf("%d\n", ans); return 0; }