結果

問題 No.497 入れ子の箱
ユーザー finefine
提出日時 2017-03-24 23:18:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 945 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 178,228 KB
実行使用メモリ 6,264 KB
最終ジャッジ日時 2023-09-20 03:42:15
合計ジャッジ時間 4,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 10 ms
5,864 KB
testcase_04 AC 10 ms
6,172 KB
testcase_05 AC 10 ms
5,984 KB
testcase_06 AC 11 ms
6,132 KB
testcase_07 AC 11 ms
6,176 KB
testcase_08 AC 11 ms
6,040 KB
testcase_09 AC 11 ms
6,000 KB
testcase_10 AC 11 ms
5,688 KB
testcase_11 AC 11 ms
5,904 KB
testcase_12 AC 10 ms
4,752 KB
testcase_13 AC 9 ms
4,776 KB
testcase_14 AC 10 ms
4,936 KB
testcase_15 AC 10 ms
4,748 KB
testcase_16 AC 10 ms
4,840 KB
testcase_17 AC 9 ms
4,992 KB
testcase_18 AC 8 ms
6,040 KB
testcase_19 AC 9 ms
6,264 KB
testcase_20 AC 8 ms
5,972 KB
testcase_21 AC 8 ms
6,028 KB
testcase_22 AC 8 ms
6,092 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 1 ms
4,388 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 9 ms
5,332 KB
testcase_28 AC 9 ms
5,452 KB
testcase_29 AC 9 ms
5,292 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef tuple<int, int, int> T;

vector< vector<int> > G;
vector<int> dist;

int dfs(int cur) {
	if (dist[cur] != 0) return dist[cur];
	int res = 0;
	for (int nex : G[cur]) {
		res = max(res, dfs(nex));
	}
	res++;
	dist[cur] = res;
	return res;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<T> b(n);
	for (int i = 0; i < n; i++) {
		int d[3];
		for (int j = 0; j < 3; j++) cin >> d[j];
		sort(d, d + 3);
		b[i] = tie(d[0], d[1], d[2]);
	}
	
	G.resize(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			int x1, y1, z1, x2, y2, z2;
			tie(x1, y1, z1) = b[i];
			tie(x2, y2, z2) = b[j];
			if (x1 < x2 && y1 < y2 && z1 < z2) {
				G[i].push_back(j);
			}
		}
	}

	dist.resize(n, 0);
	for (int i = 0; i < n; i++) {
		if (dist[i] == 0) dfs(i);
	}

	cout << *max_element(dist.begin(), dist.end()) << endl;
	return 0;
}
0