結果

問題 No.497 入れ子の箱
ユーザー uenokuuenoku
提出日時 2017-03-27 21:45:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,182 bytes
コンパイル時間 898 ms
コンパイル使用メモリ 90,212 KB
実行使用メモリ 8,616 KB
最終ジャッジ日時 2023-09-20 14:35:40
合計ジャッジ時間 2,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,632 KB
testcase_01 AC 3 ms
5,708 KB
testcase_02 AC 3 ms
5,592 KB
testcase_03 AC 15 ms
8,504 KB
testcase_04 AC 15 ms
8,452 KB
testcase_05 AC 15 ms
8,616 KB
testcase_06 AC 15 ms
8,584 KB
testcase_07 AC 15 ms
8,456 KB
testcase_08 AC 15 ms
8,472 KB
testcase_09 AC 15 ms
8,500 KB
testcase_10 AC 15 ms
8,364 KB
testcase_11 AC 15 ms
8,596 KB
testcase_12 AC 17 ms
7,148 KB
testcase_13 AC 17 ms
7,016 KB
testcase_14 AC 17 ms
7,144 KB
testcase_15 AC 18 ms
7,252 KB
testcase_16 AC 17 ms
7,240 KB
testcase_17 AC 17 ms
7,060 KB
testcase_18 AC 12 ms
8,572 KB
testcase_19 AC 12 ms
8,332 KB
testcase_20 AC 12 ms
8,336 KB
testcase_21 AC 12 ms
8,484 KB
testcase_22 AC 12 ms
8,312 KB
testcase_23 AC 7 ms
5,628 KB
testcase_24 AC 8 ms
5,732 KB
testcase_25 AC 3 ms
5,596 KB
testcase_26 AC 3 ms
5,620 KB
testcase_27 AC 15 ms
7,760 KB
testcase_28 AC 15 ms
7,660 KB
testcase_29 AC 15 ms
7,584 KB
testcase_30 AC 12 ms
5,732 KB
testcase_31 AC 12 ms
5,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int n;
vector<vector<int>> box;
vector<int> len(3), e[100005];
bool can(int i, int j)
{
    return box[i][0] > box[j][0]
           && box[i][1] > box[j][1] && box[i][2] > box[j][2];
}
lli memo[100005];
lli get(int cur, int par)
{
    if (memo[cur])
        return memo[cur];
    else {
        lli ans = 0;
        for (auto s : e[cur]) {
            if (s != par) {
                ans = max(ans, get(s, cur));
            }
        }
        return memo[cur] = ans + 1;
    }
}
int main()
{
    cin >> n;
    rep(i, n)
    {
        cin >> len[0] >> len[1] >> len[2];
        sort(len.begin(), len.end());
        box.push_back(len);
    }
    rep(i, n) rep(j, n)
    {
        if (i == j)
            continue;
        if (can(i, j)) {
            e[i].push_back(j);
        }
    }
    lli ans = 0;
    rep(i, n)
    {
        ans = max(get(i, -1), ans);
    }
    cout << ans << endl;
}
0