#ifdef __MAI #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #else #include #endif using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>= 1, k++)s = (s << 1) | (u & 1); for (; 0>= 1)cout << (s & 1); } } #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) namespace { std::chrono::system_clock::time_point t; void tic() { t = TIME; } void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); } std::chrono::system_clock::time_point tle = TIME; #ifdef __MAI void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); } #else #define safe_tle(k) ; #endif } template ostream& operator <<(ostream &o, const pair p) { o << "(" << p.first << ":" << p.second << ")"; return o; } random_device noize; // noize mt19937 mt(noize()); int rand_int(int l, int h) { uniform_int_distribution<> range(l, h); return range(mt); } #ifndef __MAI namespace { class MaiScanner { public: template void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'>(int& var) { input_integer(var); return *this; } MaiScanner& operator>>(long long& var) { input_integer(var); return *this; } }; class MaiPrinter { int stack_p; char stack[32]; public: template void output_integer(T var) { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) { putchar_unlocked('-'); var = -var; } stack_p = 0; while (var) { stack[stack_p++] = '0' + (var % 10); var /= 10; } while (stack_p) putchar_unlocked(stack[--stack_p]); } MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } MaiPrinter& operator<<(int var) { output_integer(var); return *this; } MaiPrinter& operator<<(long long var) { output_integer(var); return *this; } }; } MaiScanner scanner; MaiPrinter printer; #else #define scanner cin #endif class Graph { public: class adjacent { public: Graph& g; int id; adjacent(Graph& g, int id) :g(g), id(id) {} class iterator { public: adjacent& ref; int pointer; iterator(adjacent& ref, int p = 0) :ref(ref), pointer(p) {} iterator& operator ++() { ++pointer; return *this; } const int& operator*() const { int n1 = ref.g.vertex_to[ref.id].size(); return pointer> vertex_to; vector> vertex_from; Graph(size_t n) :n(n), vertex_to(n), vertex_from(n) {} void connect(int from, int to) { vertex_to[from].emplace_back(to); vertex_from[to].emplace_back(from); } void resize(size_t _n) { n = _n; vertex_to.resize(_n); vertex_from.resize(_n); } // for (auto to : g.vertex_adjacent(vertex_id)) な感じで使う adjacent vertex_adjacent(int idx) { return adjacent(*this, idx); } size_t degree(int v) { return vertex_to[v].size() + vertex_from[v].size(); } void reverse_direction() { vertex_from.swap(vertex_to); } }; /* ============ */ int n, m, kei; int width, height; int field[111][111]; int gx, gy; //pair kuri[111]; int hako[1010][3]; int hakodp[1010][1010]; Graph g(1); vector visit; int ahodfs(int u) { int r = 1; for (int v : g.vertex_to[u]) { r = max(r, ahodfs(v) + 1); } return r; } int main() { int i, j, k; int x, y, z; int a, b, c, d; scanner >> n; g.resize(n); for (i = 0; i < n; ++i) { scanner >> x >> y >> z; hako[i][0] = x; hako[i][1] = y; hako[i][2] = z; } for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { if ((hako[i][0] < hako[j][0] && hako[i][1] < hako[j][1] && hako[i][2] < hako[j][2]) || (hako[i][0] < hako[j][0] && hako[i][1] < hako[j][2] && hako[i][2] < hako[j][1]) || (hako[i][0] < hako[j][1] && hako[i][1] < hako[j][0] && hako[i][2] < hako[j][2]) || (hako[i][0] < hako[j][1] && hako[i][1] < hako[j][2] && hako[i][2] < hako[j][0]) || (hako[i][0] < hako[j][2] && hako[i][1] < hako[j][0] && hako[i][2] < hako[j][1]) || (hako[i][0] < hako[j][2] && hako[i][1] < hako[j][1] && hako[i][2] < hako[j][0])) { g.connect(i, j); } } } visit.resize(n); int result = 1; for (i = 0; i < n; ++i) { fill(visit.begin(), visit.end(), 0); result = max(result, ahodfs(i)); } cout << result << endl; return 0; }