結果

問題 No.497 入れ子の箱
ユーザー dnish
提出日時 2017-07-01 16:42:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,059 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 177,204 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-05 05:42:25
合計ジャッジ時間 2,469 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=1e9;

vector<pair<int,pair<int,int>>> a;

int LIS1(int n){
	int dp[1010];
	REP(i,0,n) dp[i]=inf;
	REP(i,0,n){
		*lower_bound(dp,dp+n,a[i].S.F)=a[i].S.F;
	}
	return lower_bound(dp,dp+n,inf)-dp;
}

int LIS2(int n){
	int dp[1010];
	REP(i,0,n) dp[i]=inf;
	REP(i,0,n){
		*lower_bound(dp,dp+n,a[i].S.S)=a[i].S.S;
	}
	return lower_bound(dp,dp+n,inf)-dp;
}

int main(){
	int N;
	cin>>N;
	REP(i,0,N){
		int tmp[3];
		cin>>tmp[0]>>tmp[1]>>tmp[2];
		sort(tmp,tmp+3);
		a.push_back({tmp[0],{tmp[1],tmp[2]}});
	}
	sort(a.begin(),a.end());
	//b.push_back({a[0][1],a[0][2]});
	REP(i,1,a.size()){
		if(a[i-1].F==a[i].F) {
			a.erase(a.begin()+i);
			i--;
		}
	}

	int ans=min(LIS1(a.size()),LIS2(a.size()));
	p(ans);

	return 0;
}
0