結果

問題 No.497 入れ子の箱
ユーザー fiordfiord
提出日時 2017-03-28 17:25:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 6,304 KB
最終ジャッジ日時 2023-09-20 18:32:21
合計ジャッジ時間 4,191 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 62 ms
6,128 KB
testcase_04 AC 73 ms
6,104 KB
testcase_05 AC 73 ms
6,112 KB
testcase_06 AC 73 ms
6,128 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,380 KB
testcase_24 AC 55 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 70 ms
4,380 KB
testcase_31 AC 70 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

bool contain(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 (contain(dat[i], dat[j])) {
				edge[i].push_back(j);
				rest[j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (rest[i] == 0) {
			depth[i] = 1;
			queue<int> q;
			q.push(i);
			while (!q.empty()) {
				int cur = q.front();	q.pop();
				for (int i = 0; i < edge[cur].size(); i++) {
					int to = edge[cur][i];
					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