結果

問題 No.497 入れ子の箱
ユーザー pekempeypekempey
提出日時 2017-03-24 22:35:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,098 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 77,904 KB
実行使用メモリ 7,460 KB
最終ジャッジ日時 2023-09-20 07:13:54
合計ジャッジ時間 2,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 14 ms
7,208 KB
testcase_04 AC 15 ms
7,212 KB
testcase_05 AC 15 ms
7,256 KB
testcase_06 AC 15 ms
7,192 KB
testcase_07 AC 22 ms
7,264 KB
testcase_08 AC 23 ms
7,188 KB
testcase_09 AC 22 ms
7,200 KB
testcase_10 AC 22 ms
7,212 KB
testcase_11 AC 22 ms
7,212 KB
testcase_12 AC 25 ms
7,204 KB
testcase_13 AC 25 ms
7,204 KB
testcase_14 AC 25 ms
7,200 KB
testcase_15 AC 25 ms
7,216 KB
testcase_16 AC 25 ms
7,208 KB
testcase_17 AC 25 ms
7,224 KB
testcase_18 AC 12 ms
7,212 KB
testcase_19 AC 12 ms
7,256 KB
testcase_20 AC 12 ms
7,276 KB
testcase_21 AC 12 ms
7,192 KB
testcase_22 AC 12 ms
7,196 KB
testcase_23 AC 7 ms
7,208 KB
testcase_24 AC 7 ms
7,460 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 20 ms
7,192 KB
testcase_28 AC 20 ms
7,364 KB
testcase_29 AC 20 ms
7,244 KB
testcase_30 AC 11 ms
7,216 KB
testcase_31 AC 11 ms
7,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>

using namespace std;

int g[1000][1000];
int dp[1000];
bool vis[1000];
int n;

void dfs(int u) {
	if (vis[u]) {
		return;
	}
	vis[u] = true;
	dp[u] = 1;
	for (int i = 0; i < n; i++) {
		if (g[u][i]) {
			dfs(i);
			dp[u] = max(dp[u], dp[i] + 1);
		}
	}
}

int main() {
	cin >> n;
	vector<int> x(n), y(n), z(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			bool ok = false;
			if (x[i] > x[j] && y[i] > y[j] && z[i] > z[j]) ok = true;
			if (x[i] > x[j] && y[i] > z[j] && z[i] > y[j]) ok = true;
			if (x[i] > y[j] && y[i] > x[j] && z[i] > z[j]) ok = true;
			if (x[i] > y[j] && y[i] > z[j] && z[i] > x[j]) ok = true;
			if (x[i] > z[j] && y[i] > x[j] && z[i] > y[j]) ok = true;
			if (x[i] > z[j] && y[i] > y[j] && z[i] > x[j]) ok = true;
			g[i][j] = ok;
		}
	}
	for (int i = 0; i < n; i++) {
		dfs(i);
	}
	cout << *max_element(dp, dp + n) << endl;
}
0