結果

問題 No.497 入れ子の箱
ユーザー kotatsugamekotatsugame
提出日時 2017-03-24 23:56:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 76,224 KB
実行使用メモリ 6,320 KB
最終ジャッジ日時 2023-09-20 05:52:04
合計ジャッジ時間 2,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 8 ms
6,048 KB
testcase_04 AC 9 ms
6,096 KB
testcase_05 AC 9 ms
6,036 KB
testcase_06 AC 8 ms
6,144 KB
testcase_07 AC 9 ms
6,040 KB
testcase_08 AC 9 ms
6,316 KB
testcase_09 AC 9 ms
6,100 KB
testcase_10 AC 9 ms
6,180 KB
testcase_11 AC 9 ms
6,320 KB
testcase_12 AC 10 ms
5,164 KB
testcase_13 AC 10 ms
4,800 KB
testcase_14 AC 11 ms
4,772 KB
testcase_15 AC 11 ms
4,944 KB
testcase_16 AC 11 ms
4,888 KB
testcase_17 AC 10 ms
4,848 KB
testcase_18 AC 9 ms
6,108 KB
testcase_19 AC 8 ms
6,044 KB
testcase_20 AC 9 ms
6,044 KB
testcase_21 AC 9 ms
6,220 KB
testcase_22 AC 8 ms
6,308 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 10 ms
5,424 KB
testcase_28 AC 9 ms
5,364 KB
testcase_29 AC 10 ms
5,396 KB
testcase_30 AC 8 ms
4,376 KB
testcase_31 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   37 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>G[1000];
class c
{
public:
	long x,y,z;
	c(long x=0,long y=0,long z=0):x(x),y(y),z(z){};
	void in(long ix,long iy,long iz)
	{
		x=ix;y=iy;z=iz;
		if(x>y)swap(x,y);
		if(x>z)swap(y,z),swap(x,y);
		else if(y>z)swap(y,z);
	}
	bool operator<(c a)
	{
		return a.x>x&&a.y>y&&a.z>z;
	}
};
int cnt[1000];
int f(int v)
{
	if(cnt[v]>=0)return cnt[v];
	else
	{
		cnt[v]=0;
		for(int i=0;i<G[v].size();i++)
		{
			cnt[v]=max(cnt[v],f(G[v][i])+1);
		}
		return cnt[v];
	}
}
main()
{
	int n;cin>>n;
	c a[1000];
	for(int i=0;i<n;i++)
	{
		long x,y,z;cin>>x>>y>>z;
		a[i].in(x,y,z);
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-j&&a[j]<a[i])G[i].push_back(j);
		}
	}
	int m=0;
	for(int i=0;i<n;i++)cnt[i]=-1;
	for(int i=0;i<n;i++)
	{
		m=max(m,f(i)+1);
	}
	cout<<m<<endl;
}
0