結果

問題 No.497 入れ子の箱
ユーザー recososorecososo
提出日時 2020-06-14 15:14:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 1,426 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 176,060 KB
実行使用メモリ 7,204 KB
最終ジャッジ日時 2023-09-09 17:59:37
合計ジャッジ時間 5,523 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 172 ms
7,080 KB
testcase_04 AC 171 ms
7,108 KB
testcase_05 AC 171 ms
7,136 KB
testcase_06 AC 171 ms
7,156 KB
testcase_07 AC 171 ms
7,156 KB
testcase_08 AC 172 ms
7,192 KB
testcase_09 AC 172 ms
7,124 KB
testcase_10 AC 172 ms
7,100 KB
testcase_11 AC 171 ms
7,204 KB
testcase_12 AC 23 ms
4,984 KB
testcase_13 AC 29 ms
4,924 KB
testcase_14 AC 21 ms
4,948 KB
testcase_15 AC 22 ms
4,884 KB
testcase_16 AC 25 ms
5,232 KB
testcase_17 AC 26 ms
4,932 KB
testcase_18 AC 151 ms
6,708 KB
testcase_19 AC 285 ms
6,700 KB
testcase_20 AC 144 ms
6,656 KB
testcase_21 AC 81 ms
6,748 KB
testcase_22 AC 81 ms
6,684 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 16 ms
5,484 KB
testcase_28 AC 16 ms
5,528 KB
testcase_29 AC 17 ms
5,420 KB
testcase_30 AC 7 ms
4,380 KB
testcase_31 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<vector<int>> e(n);
    vector<vector<int>> d(n,vector<int>(3));
    int ans=1;
    rep(i,n){
        rep(j,3){
            cin >> d[i][j];
        }
        sort(d[i].begin(),d[i].end());
    }
    vector<int> h(n);
    rep(i,n){
        rep(j,n){
            if(d[i][0]<d[j][0]&&d[i][1]<d[j][1]&&d[i][2]<d[j][2]){
                e[i].push_back(j);
                h[j]++;
            }
        }
    }
    rep(i,n){
        if(h[i]){
            continue;
        }
        queue<int> q;
        q.push(i);
        vector<int> d(n,1);
        while(!q.empty()){
            int p=q.front();
            q.pop();
            for(int x:e[p]){
                if(chmax(d[x],d[p]+1)){
                    q.push(x);
                }
            }
        }
        int res=0;
        rep(j,n){
            chmax(res,d[j]);
        }
        chmax(ans,res);
    }
    cout << ans << endl;
}
0