結果

問題 No.497 入れ子の箱
ユーザー face4face4
提出日時 2019-02-13 18:17:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 1,085 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 78,548 KB
実行使用メモリ 6,200 KB
最終ジャッジ日時 2023-10-11 12:22:00
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 10 ms
6,140 KB
testcase_04 AC 11 ms
6,080 KB
testcase_05 AC 11 ms
6,072 KB
testcase_06 AC 11 ms
6,080 KB
testcase_07 AC 12 ms
6,192 KB
testcase_08 AC 12 ms
6,052 KB
testcase_09 AC 11 ms
6,188 KB
testcase_10 AC 11 ms
6,140 KB
testcase_11 AC 11 ms
6,064 KB
testcase_12 AC 12 ms
4,984 KB
testcase_13 AC 12 ms
4,836 KB
testcase_14 AC 13 ms
4,804 KB
testcase_15 AC 12 ms
5,088 KB
testcase_16 AC 12 ms
4,844 KB
testcase_17 AC 13 ms
4,780 KB
testcase_18 AC 8 ms
6,200 KB
testcase_19 AC 8 ms
6,112 KB
testcase_20 AC 8 ms
6,100 KB
testcase_21 AC 9 ms
6,152 KB
testcase_22 AC 8 ms
6,028 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 4 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 10 ms
5,448 KB
testcase_28 AC 10 ms
5,324 KB
testcase_29 AC 11 ms
5,264 KB
testcase_30 AC 6 ms
4,352 KB
testcase_31 AC 7 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;

    vector<int> x(n), y(n), z(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> z[i];
        if(y[i] > z[i]) swap(y[i], z[i]);
        if(x[i] > y[i]) swap(x[i], y[i]);
        if(y[i] > z[i]) swap(y[i], z[i]);
    }

    vector<int> v[n], indeg(n, 0);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j)  continue;
            if(x[i] < x[j] && y[i] < y[j] && z[i] < z[j]){
                v[i].push_back(j);
                indeg[j]++;
            }
        }
    }

    vector<int> ans(n, 1);
    queue<int> q;
    for(int i = 0; i < n; i++){
        if(indeg[i] == 0)   q.push(i);
    }

    int ret = 0;
    while(!q.empty()){
        int p = q.front();  q.pop();
        ret = max(ret, ans[p]);
        for(int next : v[p]){
            indeg[next]--;
            ans[next] = max(ans[next], ans[p]+1);
            if(indeg[next] == 0)    q.push(next);
        }
    }

    cout << ret << endl;

    return 0;
}
0