結果

問題 No.497 入れ子の箱
ユーザー dnishdnish
提出日時 2017-07-01 17:31:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,209 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 177,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 08:01:56
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 4 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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){
	vector<pair<int,int>> dp;
	dp.push_back({a[0].S.F,a[0].S.S});
	REP(i,1,n){
		REP(j,0,dp.size()){
			if(dp[j].F>a[i].S.F && dp[j].S>a[i].S.S) {
				dp[j]={a[i].S.F,a[i].S.S};
				break;
			}
		}
		if(dp.back().F<a[i].S.F && dp.back().S<a[i].S.S) dp.push_back({a[i].S.F,a[i].S.S});
	}
	return dp.size();
}

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