結果
問題 |
No.497 入れ子の箱
|
ユーザー |
![]() |
提出日時 | 2025-07-16 20:38:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 105 ms / 5,000 ms |
コード長 | 747 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 82,392 KB |
実行使用メモリ | 81,384 KB |
最終ジャッジ日時 | 2025-07-16 20:38:52 |
合計ジャッジ時間 | 4,774 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
N = int(input()) XYZ = [] for i in range(N): xyz = list(map(int,input().split())) xyz.sort() XYZ.append(xyz) E = [[] for _ in range(N)] D = [0] * N for i in range(N-1): x1,y1,z1 = XYZ[i] for j in range(i+1,N): x2,y2,z2 = XYZ[j] if x1 > x2 and y1 > y2 and z1 > z2: E[j].append(i) D[i] += 1 if x1 < x2 and y1 < y2 and z1 < z2: E[i].append(j) D[j] += 1 Q = [] for i in range(N): if D[i] == 0: Q.append(i) dp = [1] * N Q2 = [] while Q: while Q: x = Q.pop() for y in E[x]: dp[y] = max(dp[y],dp[x]+1) D[y] -= 1 if D[y] == 0: Q2.append(y) Q,Q2 = Q2,Q print(max(dp))