結果

問題 No.497 入れ子の箱
ユーザー ei1333333ei1333333
提出日時 2017-03-24 22:42:35
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,757 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 84,440 KB
実行使用メモリ 44,136 KB
最終ジャッジ日時 2023-09-20 01:48:22
合計ジャッジ時間 8,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
43,856 KB
testcase_01 AC 23 ms
43,872 KB
testcase_02 AC 23 ms
43,860 KB
testcase_03 AC 24 ms
44,136 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 24 ms
43,868 KB
testcase_24 RE -
testcase_25 AC 24 ms
43,996 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;
#define INF (1 << 30)
typedef pair< int, int > P;


int C = ~(1 << 31), M = (1 << 16) - 1;
int n, x, y, z;

template< typename T >
T next(T a)
{
  return ++a;
}

template< typename T >
T before(T a)
{
  return --a;
}

vector< P > points[1080000];
set< P > dp[324000];

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++) {
    vector< int > v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(begin(v), end(v));
    points[v[0]].push_back(P(-v[1], v[2]));
  }
  for(int i = 0; i < 324000; i++) {
    while(!dp[i].empty())dp[i].erase(dp[i].begin());
  }
  dp[0].insert(P(-INF, -INF));
  int res = 0;
  for(int i = 0; i < 1080000; i++) {
    sort(points[i].begin(), points[i].end());
    for(int j = 0; j < points[i].size(); j++) {
      y = -points[i][j].first;
      z = points[i][j].second;
      int bottom = 0, top = 324000;
      while(top - bottom > 1) {
        int mid = (top + bottom) / 2;
        if(dp[mid].empty()) {
          top = mid;
          continue;
        }
        set< P >::iterator it = dp[mid].lower_bound(P(y, -INF));
        if(it == dp[mid].begin()) {
          top = mid;
          continue;
        }
        it--;
        if(it->second < z)bottom = mid;
        else top = mid;
      }
      bottom++;
      res = max(res, bottom);
      dp[bottom].insert(P(y, z));
      set< P >::iterator it = dp[bottom].find(P(y, z));

      if(it != dp[bottom].begin() && before(it)->second <= z) {
        dp[bottom].erase(it);
        continue;
      }
      it++;
      while(it != dp[bottom].end() && it->second >= z) {
        dp[bottom].erase(it++);
      }
    }
    points[i].clear();
  }
  cout << res << endl;

  return 0;
}
0