結果

問題 No.497 入れ子の箱
ユーザー Hoget157Hoget157
提出日時 2017-03-24 23:04:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,787 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 101,084 KB
実行使用メモリ 9,044 KB
最終ジャッジ日時 2023-09-20 02:50:54
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 32 ms
8,808 KB
testcase_04 AC 49 ms
9,044 KB
testcase_05 AC 49 ms
8,784 KB
testcase_06 AC 50 ms
8,856 KB
testcase_07 AC 50 ms
8,752 KB
testcase_08 AC 49 ms
8,692 KB
testcase_09 AC 49 ms
8,752 KB
testcase_10 AC 49 ms
8,844 KB
testcase_11 AC 49 ms
8,564 KB
testcase_12 AC 48 ms
6,348 KB
testcase_13 AC 49 ms
6,252 KB
testcase_14 AC 48 ms
6,260 KB
testcase_15 AC 48 ms
6,568 KB
testcase_16 AC 48 ms
6,428 KB
testcase_17 AC 49 ms
6,184 KB
testcase_18 AC 46 ms
8,728 KB
testcase_19 AC 47 ms
8,604 KB
testcase_20 AC 46 ms
8,800 KB
testcase_21 AC 46 ms
8,596 KB
testcase_22 AC 47 ms
8,612 KB
testcase_23 AC 22 ms
4,380 KB
testcase_24 AC 23 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 49 ms
7,256 KB
testcase_28 AC 48 ms
7,132 KB
testcase_29 AC 48 ms
7,136 KB
testcase_30 AC 33 ms
4,380 KB
testcase_31 AC 33 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
//typedef    pair<int,int>      P;
 
const int INF=1e+13;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

bool comp(int x,int y,int z,int xx,int yy,int zz){
	int a[] = {x,y,z},b[] = {xx,yy,zz};
	sort(a,a + 3);
	sort(b,b + 3);
	for(int i = 0;i < 3;i++){
		if(a[i] >= b[i]) return false;
	}
	return true;
}

signed main(){
	int n,x[1000],y[1000],z[1000],in[1000] = {},cnt[1000] = {};
	vector<int> G[1000];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i] >> y[i] >> z[i];
	for(int i = 0;i < n;i++) cnt[i] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(comp(x[i],y[i],z[i],x[j],y[j],z[j])) {
				G[i].push_back(j);
				in[j]++;
			}
		}
	}
	queue<int> que;
	for(int i = 0;i < n;i++){
		if(in[i] == 0) {
			que.push(i);
			cnt[i] = 1;
		}
	}
	while(!que.empty()){
		int v = que.front();que.pop();
		for(int i = 0;i < G[v].size();i++){
			int to = G[v][i];
			cnt[to] = max(cnt[to],cnt[v] + 1);
			in[to]--;
			if(in[to] == 0){
				que.push(to);
			}
		}
	}
	int ma = 0;
	for(int i = 0;i < n;i++) ma = max(ma,cnt[i]);
	cout << ma << endl;
	return 0;
}
0