結果

問題 No.497 入れ子の箱
ユーザー kktykkty
提出日時 2017-11-06 20:59:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,232 bytes
コンパイル時間 1,737 ms
コンパイル使用メモリ 171,692 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2024-05-03 06:23:15
合計ジャッジ時間 8,878 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 62 ms
5,376 KB
testcase_24 AC 63 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 83 ms
5,376 KB
testcase_31 AC 83 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 30);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

bool contains(vi a,vi b) {
  sort(ALL(b));
  do {
    if(a[0]>b[0]&&a[1]>b[1]&&a[2]>b[2]) return true;
  } while(next_permutation(ALL(b)));
  return false;
}

int main() {
  ll N; cin>>N;
  Graph G(N);

  {
    vvi v(N,vi(3)); REP(i,N) cin>>v[i][0]>>v[i][1]>>v[i][2];
    REP(i,N) {
      REP(j,N) {
        if(contains(v[i],v[j])) {
          G[i].PB(j);
        }
      }
    }
  }

  ll ans=0;
  REP(root,N) {
    vi cnt(N,0);
    queue<ll> q;
    q.push(root);
    cnt[root]=1;
    while(q.size()) {
      ll from=q.front(); q.pop();
      for(ll to:G[from]) {
        if(cnt[to]==0) {
          q.push(to);
        }
        cnt[to]=max(cnt[to],cnt[from]+1);
      }
    }
    ll ma=0;
    for(ll i:cnt) ans=max(ans,i);
  }
  cout<<ans<<endl;
}
0