結果

問題 No.497 入れ子の箱
ユーザー tottoripapertottoripaper
提出日時 2017-03-24 22:39:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,392 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 149,044 KB
実行使用メモリ 6,192 KB
最終ジャッジ日時 2023-09-20 07:16:05
合計ジャッジ時間 2,860 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 11 ms
5,888 KB
testcase_04 AC 10 ms
5,984 KB
testcase_05 AC 11 ms
6,012 KB
testcase_06 AC 11 ms
6,020 KB
testcase_07 AC 11 ms
6,084 KB
testcase_08 AC 11 ms
6,060 KB
testcase_09 AC 11 ms
5,944 KB
testcase_10 AC 10 ms
6,192 KB
testcase_11 AC 11 ms
6,080 KB
testcase_12 AC 12 ms
4,888 KB
testcase_13 AC 12 ms
4,772 KB
testcase_14 AC 12 ms
4,988 KB
testcase_15 AC 12 ms
4,828 KB
testcase_16 AC 12 ms
4,840 KB
testcase_17 AC 12 ms
4,788 KB
testcase_18 AC 10 ms
5,860 KB
testcase_19 AC 11 ms
5,852 KB
testcase_20 AC 10 ms
5,904 KB
testcase_21 AC 11 ms
5,888 KB
testcase_22 AC 11 ms
5,848 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 10 ms
5,384 KB
testcase_28 AC 11 ms
5,400 KB
testcase_29 AC 10 ms
5,400 KB
testcase_30 AC 9 ms
4,380 KB
testcase_31 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
int Xs[1000][3];
std::vector<int> G[1000];
int d[1000];

int dfs(int v){
    if(d[v] != -1){return d[v];}
    
    int r = 1;

    for(int w : G[v]){
        r = max(r, dfs(w) + 1);
    }

    return d[v] = r;
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    memset(d, -1, sizeof(d));
    
    std::cin >> N;

    for(int i=0;i<N;++i){
        for(int j=0;j<3;++j){
            std::cin >> Xs[i][j];
        }

        sort(&Xs[0][0] + i * 3, &Xs[0][0] + i * 3 + 3);

        // for(int j=0;j<3;++j){
        //     std::cout << Xs[i][j] << std::endl;
        // }
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(i == j){continue;}

            bool ok = true;
            for(int k=0;k<3;++k){
                if(Xs[i][k] <= Xs[j][k]){
                    ok = false;
                    break;
                }
            }

            if(ok){
                G[i].emplace_back(j);
            }
        }
    }

    int res = 0;
    for(int i=0;i<N;++i){
        res = max(res, dfs(i));
    }

    std::cout << res << std::endl;
}
0