結果
| 問題 | No.497 入れ子の箱 |
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2017-03-28 08:47:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 980 bytes |
| 記録 | |
| コンパイル時間 | 943 ms |
| コンパイル使用メモリ | 83,024 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 13:08:10 |
| 合計ジャッジ時間 | 3,829 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
vector<int> edge[1000];
int rest[1000];
int depth[1000];
bool ok(vector<int> a,vector<int> b){
do{
if(a[0]>b[0]&&a[1]>b[1]&&a[2]>b[2]) return true;
}while(next_permutation(b.begin(),b.end()));
return false;
}
int main(){
int n; cin>>n;
vector<vector<int>> dat(n,vector<int>(3));
for(int i=0;i<n;i++) cin>>dat[i][0]>>dat[i][1]>>dat[i][2];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(ok(dat[i],dat[j])){
edge[i].push_back(j);
rest[j]++;
}
}
}
for(int i=0;i<n;i++){
if(rest[i]==0){
queue<int> q;
q.push(i);
depth[i]=1;
while(!q.empty()){
int cur=q.front(); q.pop();
for(int j=0;j<edge[cur].size();j++){
int to=edge[cur][j];
depth[to]=max(depth[to],depth[cur]+1);
rest[to]--;
if(rest[to]==0) q.push(to);
}
}
}
}
int ret=0;
for(int i=0;i<n;i++) ret=max(ret,depth[i]);
cout<<ret<<endl;
return 0;
}
fiord