結果

問題 No.497 入れ子の箱
ユーザー tossytossy
提出日時 2017-04-05 22:48:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 922 ms / 5,000 ms
コード長 1,196 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 167,768 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-09-22 20:28:22
合計ジャッジ時間 27,914 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,256 KB
testcase_01 AC 4 ms
7,324 KB
testcase_02 AC 4 ms
7,244 KB
testcase_03 AC 917 ms
7,252 KB
testcase_04 AC 913 ms
7,344 KB
testcase_05 AC 922 ms
7,304 KB
testcase_06 AC 914 ms
7,260 KB
testcase_07 AC 915 ms
7,252 KB
testcase_08 AC 913 ms
7,268 KB
testcase_09 AC 912 ms
7,320 KB
testcase_10 AC 917 ms
7,544 KB
testcase_11 AC 916 ms
7,268 KB
testcase_12 AC 918 ms
7,252 KB
testcase_13 AC 914 ms
7,260 KB
testcase_14 AC 913 ms
7,256 KB
testcase_15 AC 916 ms
7,252 KB
testcase_16 AC 920 ms
7,256 KB
testcase_17 AC 919 ms
7,360 KB
testcase_18 AC 915 ms
7,316 KB
testcase_19 AC 916 ms
7,316 KB
testcase_20 AC 914 ms
7,268 KB
testcase_21 AC 911 ms
7,572 KB
testcase_22 AC 915 ms
7,364 KB
testcase_23 AC 914 ms
7,320 KB
testcase_24 AC 911 ms
7,268 KB
testcase_25 AC 4 ms
7,240 KB
testcase_26 AC 4 ms
7,352 KB
testcase_27 AC 914 ms
7,408 KB
testcase_28 AC 912 ms
7,284 KB
testcase_29 AC 916 ms
7,264 KB
testcase_30 AC 917 ms
7,304 KB
testcase_31 AC 916 ms
7,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 21474836
#define long long long // for codeforces

int d[1000][1000];

int main(){
  int n;
  cin>>n;
  vector<int> a(n), b(n), c(n);
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
    if(a[i]>b[i]) swap(a[i],b[i]);
    if(b[i]>c[i]) swap(b[i],c[i]);
    if(a[i]>b[i]) swap(a[i],b[i]);
  }

  fill(d[0], d[1000], -INF);
  rep(i,n) rep(j,n) if(i!=j){
    if(a[i]<a[j] && b[i]<b[j] && c[i]<c[j]) d[i][j] = 1;
  }

  rep(k,n) rep(i,n) rep(j,n) d[i][j] = max(d[i][j], d[i][k] + d[k][j]);

  int ans = 0;
  rep(i,n) rep(j,n) ans = max(ans, d[i][j]);

  cout << ans+1 << endl;

  return 0;
}
0