結果

問題 No.497 入れ子の箱
ユーザー confconf
提出日時 2017-03-17 03:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 83,420 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-20 05:20:05
合計ジャッジ時間 2,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 13 ms
6,084 KB
testcase_04 AC 14 ms
6,048 KB
testcase_05 AC 14 ms
6,044 KB
testcase_06 AC 14 ms
6,136 KB
testcase_07 AC 18 ms
6,080 KB
testcase_08 AC 17 ms
6,100 KB
testcase_09 AC 17 ms
6,060 KB
testcase_10 AC 18 ms
6,060 KB
testcase_11 AC 17 ms
6,032 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 10 ms
4,376 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <assert.h> 
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;
typedef tuple<int,int,int> T;
typedef vector<vector<int>> Graph;

bool putin(T &A, T &B){//AがBに入るか
    int Ax,Ay,Az,Bx,By,Bz;
    tie(Ax,Ay,Az)=A;
    tie(Bx,By,Bz)=B;
    if(Ax<Bx&&Ay<By&&Az<Bz) return true;
    if(Ax<Bx&&Ay<Bz&&Az<By) return true;
    if(Ax<By&&Ay<Bx&&Az<Bz) return true;
    if(Ax<By&&Ay<Bz&&Az<Bx) return true;
    if(Ax<Bz&&Ay<Bx&&Az<By) return true;
    if(Ax<Bz&&Ay<By&&Az<Bx) return true;
    return false;
}
Graph G(1000);
int memo[1000];

int dfs(int i){
    if(!memo[i]){
        memo[i]=1;
        for(auto to:G[i]) memo[i]=max(memo[i],dfs(i)+1);
    }
    return memo[i];
}

int main(){
    int N;
    cin>>N;
    assert(1<=N&&N<=1000);
    vector<T> B;
    for(int i=0;i<N;i++){
        int X,Y,Z;
        cin>>X>>Y>>Z;
        assert(1<=X&&X<100000000);
        assert(1<=Y&&Y<100000000);
        assert(1<=Z&&Z<100000000);
        B.emplace_back(X,Y,Z);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(putin(B[i],B[j])) G[i].push_back(j);
        }
    }
    int ans = 0;
    for(int i=0;i<N;i++) ans = max(ans, dfs(i));
    cout<<ans<<endl;
}
0