結果

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

ソースコード

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 int inf=1e9;

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

int LIS1(int n){
	pair<int,int> dp[1010];
	REP(i,0,n) dp[i]={inf,inf};
	REP(i,0,n){
		*lower_bound(dp,dp+n,a[i].S)=a[i].S;
	}
	return lower_bound(dp,dp+n,make_pair(inf,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=LIS1(a.size());
	p(ans);

	return 0;
}
0