結果

問題 No.1045 直方体大学
ユーザー kotatsugamekotatsugame
提出日時 2020-05-01 21:45:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 690 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 69,184 KB
実行使用メモリ 9,616 KB
最終ジャッジ日時 2023-08-26 08:55:36
合計ジャッジ時間 3,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
int A[3][16];
int dp[1<<16][16][6];
int dx[6]={0,0,1,1,2,2};
int dy[6]={1,2,0,2,0,1};
int dz[6]={2,1,2,0,1,0};
main()
{
	cin>>N;
	for(int i=0;i<N;i++)for(int j=0;j<3;j++)cin>>A[i][j];
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<6;j++)dp[1<<i][i][j]=A[i][dz[j]];
	}
	int ans=0;
	for(int i=1;i<1<<N;i++)for(int j=0;j<N;j++)for(int k=0;k<6;k++)
	{
		if(dp[i][j][k]==0)continue;
		ans=max(ans,dp[i][j][k]);
		for(int l=0;l<N;l++)if(!(i>>l&1))for(int m=0;m<6;m++)
		{
			if(A[j][dx[k]]>=A[l][dx[m]]&&A[j][dy[k]]>=A[l][dy[m]])
			{
				dp[i|1<<l][l][m]=max(dp[i|1<<l][l][m],dp[i][j][k]+A[l][dz[m]]);
			}
		}
	}
	cout<<ans<<endl;
}
0