結果

問題 No.497 入れ子の箱
ユーザー fiordfiord
提出日時 2017-03-28 08:47:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 6,440 KB
最終ジャッジ日時 2023-09-20 18:13:17
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 61 ms
6,188 KB
testcase_04 AC 73 ms
6,100 KB
testcase_05 AC 73 ms
6,264 KB
testcase_06 AC 73 ms
6,184 KB
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 -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 54 ms
4,376 KB
testcase_24 AC 55 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 70 ms
4,376 KB
testcase_31 AC 70 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

vector<int> edge[1000];
int rest[1000];
int depth[1000];

bool ok(vector<int> a,vector<int> b){
	do{
		if(a[0]>b[0]&&a[1]>b[1]&&a[2]>b[2])	return true;
	}while(next_permutation(b.begin(),b.end()));
	return false;
}

int main(){
	int n;	cin>>n;
	vector<vector<int>> dat(n,vector<int>(3));
	for(int i=0;i<n;i++)	cin>>dat[i][0]>>dat[i][1]>>dat[i][2];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(ok(dat[i],dat[j])){
				edge[i].push_back(j);
				rest[j]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(rest[i]==0){
			queue<int> q;
			q.push(i);
			depth[i]=1;
			while(!q.empty()){
				int cur=q.front();	q.pop();
				for(int j=0;j<edge[cur].size();j++){
					int to=edge[cur][j];
					depth[to]=max(depth[to],depth[cur]+1);
					rest[to]--;
					if(rest[to]==0)	q.push(to);
				}
			}
		}
	}
	int ret=0;
	for(int i=0;i<n;i++)	ret=max(ret,depth[i]);
	cout<<ret<<endl;
	return 0;
}
0