結果

問題 No.497 入れ子の箱
ユーザー uzumakiyorumunnuzumakiyorumunn
提出日時 2017-06-09 21:13:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,025 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 64,176 KB
実行使用メモリ 10,424 KB
最終ジャッジ日時 2023-10-23 21:00:45
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define NMAX 1000

vector<int> vi[NMAX];
bool use[NMAX];
int memo[NMAX];

int search(int n);

int main(){

	int N;
	long long x[NMAX],y[NMAX],z[NMAX];
	int ans=0;

	cin>>N;
	for(int i=0;i<N;i++){
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j) continue;
			if((x[i]>x[j]&&y[i]>y[j]&&z[i]>z[j])||(x[i]>x[j]&&y[i]>z[j]&&z[i]>y[j])||(x[i]>y[j]&&y[i]>x[j]&&z[i]>z[j])||(x[i]>y[j]&&y[i]>z[j]&&z[i]>x[j])||(x[i]>z[j]&&y[i]>y[j]&&z[i]>x[j])||(x[i]>z[j]&&y[i]>x[j]&&z[i]>y[j])){
				vi[i].push_back(j);
			}
		}
	}

	for(int i=0;i<N;i++){
		memo[i]=-1;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++) use[j]=false;
		use[i]=true;
		ans=max(ans,search(i));
	}

	cout<<ans<<endl;
}

int search(int n){

	if(memo[n]!=-1) return memo[n];
	int c=0;
	for(int i=0;i<vi[n].size();i++){
		if(!use[vi[n][i]]){
			use[vi[n][i]]=true;
			c=max(c,search(vi[n][i]));
			use[vi[n][i]]=false;
		}
	}
	return c+1;
}
0