結果

問題 No.497 入れ子の箱
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-03-24 23:05:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 427 ms / 5,000 ms
コード長 1,880 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 94,772 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2023-09-20 02:57:01
合計ジャッジ時間 6,396 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 422 ms
8,536 KB
testcase_04 AC 420 ms
8,928 KB
testcase_05 AC 423 ms
8,856 KB
testcase_06 AC 421 ms
8,624 KB
testcase_07 AC 425 ms
8,960 KB
testcase_08 AC 424 ms
8,540 KB
testcase_09 AC 424 ms
8,536 KB
testcase_10 AC 425 ms
8,556 KB
testcase_11 AC 427 ms
8,592 KB
testcase_12 AC 29 ms
6,344 KB
testcase_13 AC 29 ms
6,308 KB
testcase_14 AC 29 ms
6,180 KB
testcase_15 AC 29 ms
6,200 KB
testcase_16 AC 29 ms
6,360 KB
testcase_17 AC 29 ms
6,220 KB
testcase_18 AC 60 ms
8,680 KB
testcase_19 AC 59 ms
8,732 KB
testcase_20 AC 54 ms
8,780 KB
testcase_21 AC 69 ms
8,612 KB
testcase_22 AC 66 ms
8,920 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 26 ms
7,288 KB
testcase_28 AC 27 ms
7,324 KB
testcase_29 AC 27 ms
7,232 KB
testcase_30 AC 11 ms
4,376 KB
testcase_31 AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

vector<vector<ll> > vv;
ll d[1010];

void dfs(ll p, ll c){
  if(d[p]<c){
    d[p] = c;
  }
  else{
    return;
  }
  rep(i,0,vv[p].sz){
    dfs(vv[p][i],c+1);
  }
}

int main(){
  ll n;
  cin>>n;
  vector<ll> vx;
  vector<ll> vy;
  vector<ll> vz;
  rep(i,0,n){
    ll a,b,c;
    cin>>a>>b>>c;
    vx.pb(a);
    vy.pb(b);
    vz.pb(c);
  }
  vector<vector<ll> > vv_(n+2,vector<ll>());
  vv = vv_;
  rep(i,0,n){
    rep(j,0,n){
      if(i==j)continue;
      if(vx[i]<vx[j]&&vy[i]<vy[j]&&vz[i]<vz[j]){
        vv[i+1].pb(j+1);
      }
      else if(vx[i]<vx[j]&&vy[i]<vz[j]&&vz[i]<vy[j]){
        vv[i+1].pb(j+1);
      }
      else if(vx[i]<vy[j]&&vy[i]<vx[j]&&vz[i]<vz[j]){
        vv[i+1].pb(j+1);
      }
      else if(vx[i]<vy[j]&&vy[i]<vz[j]&&vz[i]<vx[j]){
        vv[i+1].pb(j+1);
      }
      else if(vx[i]<vz[j]&&vy[i]<vx[j]&&vz[i]<vy[j]){
        vv[i+1].pb(j+1);
      }
      else if(vx[i]<vz[j]&&vy[i]<vy[j]&&vz[i]<vx[j]){
        vv[i+1].pb(j+1);
      }
    }
  }
  rep(i,0,n){
    vv[0].pb(i+1);
  }
  rep(i,0,n){
    vv[i+1].pb(n+1);
  }
  clr(d,0);
  dfs(0,1);
  cout << d[n+1]-2 << endl;
  return 0;
}
0