結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-22 21:35:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 5,000 ms |
| コード長 | 948 bytes |
| コンパイル時間 | 1,798 ms |
| コンパイル使用メモリ | 168,472 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-22 21:35:26 |
| 合計ジャッジ時間 | 3,560 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<bits/stdc++.h>
const int N=1010; std::vector<int>g[N]; int deg[N],dp[N];
struct Box { int x,y,z; }a[N];
int main() {
//freopen("box.in","r",stdin);
//freopen("box.out","w",stdout);
std::ios::sync_with_stdio(false),std::cin.tie(nullptr);
int n; std::cin>>n;
for(int i=1;i<=n;i++) {
std::cin>>a[i].x>>a[i].y>>a[i].z;
if(a[i].x>a[i].y) std::swap(a[i].x,a[i].y);
if(a[i].x>a[i].z) std::swap(a[i].x,a[i].z);
if(a[i].y>a[i].z) std::swap(a[i].y,a[i].z);
}
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(a[i].x<a[j].x&&a[i].y<a[j].y&&a[i].z<a[j].z) g[i].push_back(j),deg[j]++;
std::queue<int>q;
for(int i=1;i<=n;i++) if(!deg[i]) q.push(i),dp[i]=1;
while(!q.empty()) {
int u=q.front(); q.pop();
for(auto v:g[u]) if(!(--deg[v])) dp[v]=dp[u]+1,q.push(v);
}
int ans=0;
for(int i=1;i<=n;i++) ans=std::max(ans,dp[i]);
std::cout<<ans;
return 0;
}
vjudge1