結果

問題 No.497 入れ子の箱
ユーザー brthyyjpbrthyyjp
提出日時 2021-02-11 12:46:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,270 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,468 KB
実行使用メモリ 79,988 KB
最終ジャッジ日時 2023-09-25 01:49:11
合計ジャッジ時間 10,089 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,532 KB
testcase_01 AC 92 ms
71,352 KB
testcase_02 AC 91 ms
71,296 KB
testcase_03 AC 201 ms
78,576 KB
testcase_04 AC 321 ms
79,456 KB
testcase_05 AC 313 ms
79,408 KB
testcase_06 AC 315 ms
79,140 KB
testcase_07 AC 317 ms
79,356 KB
testcase_08 AC 316 ms
79,304 KB
testcase_09 AC 316 ms
79,408 KB
testcase_10 AC 318 ms
79,380 KB
testcase_11 AC 325 ms
79,352 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 AC 340 ms
79,636 KB
testcase_21 AC 338 ms
79,832 KB
testcase_22 AC 342 ms
79,988 KB
testcase_23 AC 103 ms
76,756 KB
testcase_24 AC 102 ms
76,828 KB
testcase_25 AC 90 ms
71,140 KB
testcase_26 AC 92 ms
71,616 KB
testcase_27 AC 310 ms
79,048 KB
testcase_28 AC 315 ms
79,232 KB
testcase_29 AC 307 ms
79,304 KB
testcase_30 AC 107 ms
76,860 KB
testcase_31 AC 241 ms
78,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():

    n = int(input())
    XYZ = []
    X = []
    for i in range(n):
        temp = list(map(int, input().split()))
        temp.sort()
        x, y, z = temp
        XYZ.append((x, y, z))
        X.append(x)

    X = sorted(list(set(X)))
    d = {}
    for i, x in enumerate(X):
        d[x] = i

    N = len(d)
    YZ = [[] for i in range(N)]
    for x, y, z in XYZ:
        YZ[d[x]].append((y, z))

    from collections import defaultdict
    dp = defaultdict(lambda:1)
    mod =10**9
    for y, z in YZ[0]:
        dp[y*mod+z] = 1
        dp[z*mod+y] = 1
    for i in range(1, N):
        nx = defaultdict(lambda:1)
        for k, v in dp.items():
            nx[k] = max(nx[k], v)
        for ny, nz in YZ[i]:
            for k, v in dp.items():
                y, z = divmod(k, mod)
                if y < ny and z < nz:
                    nk = ny*mod+nz
                    nx[nk] = max(nx[nk], dp[k]+1)
                if y < nz and z < ny:
                    nk = nz*mod+ny
                    nx[nk] = max(nx[nk], dp[k]+1)

        dp = nx
    ans = 1
    for k, v in dp.items():
        ans = max(ans, v)
    print(ans)

if __name__ == '__main__':
    main()
0