結果

問題 No.1045 直方体大学
ユーザー 👑 kmjpkmjp
提出日時 2020-05-01 22:14:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,371 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 200,040 KB
実行使用メモリ 40,532 KB
最終ジャッジ日時 2023-08-26 14:30:31
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
40,212 KB
testcase_01 AC 10 ms
40,424 KB
testcase_02 AC 10 ms
40,220 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 10 ms
40,276 KB
testcase_06 AC 10 ms
40,288 KB
testcase_07 AC 10 ms
40,288 KB
testcase_08 AC 45 ms
40,280 KB
testcase_09 AC 38 ms
40,432 KB
testcase_10 AC 29 ms
40,360 KB
testcase_11 AC 37 ms
40,240 KB
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>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[16][3];
int ma[1<<16][16][3][3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(ma);
	cin>>N;
	FOR(i,N) {
		cin>>X[i][0]>>X[i][1]>>X[i][2];
		FOR(x,3) FOR(y,3) if(x!=y) ma[1<<i][i][x][y]=X[i][3-x-y];
	}
	
	int ret=0;
	for(int mask=0;mask<1<<N;mask++) FOR(i,N) if(mask&(1<<i)) {
		FOR(x,3) FOR(y,3) if(x!=y && ma[mask][i][x][y]>=0) {
			ret=max(ret,ma[mask][i][x][y]);
			
			FOR(j,N) if((mask&(1<<j))==0) {
				int x2,y2;
				FOR(x2,3) FOR(y2,3) if(x2!=y2) {
					if(X[j][x2]>=X[i][x]) continue;
					if(X[j][y2]>=X[i][y]) continue;
					ma[mask|(1<<j)][j][x2][y2]=max(ma[mask|(1<<j)][j][x2][y2],ma[mask][i][x][y]+X[j][3-x2-y2]);
				}
			}
			
		}
	}
	
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0