結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-24 23:18:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 5,000 ms |
| コード長 | 945 bytes |
| コンパイル時間 | 1,931 ms |
| コンパイル使用メモリ | 181,104 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2024-07-06 00:00:19 |
| 合計ジャッジ時間 | 2,601 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#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;
}