#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
const int maxn = 5e4 + 10;
int n, t1, t2, t3, tot, ans, r1[maxn], r2[maxn << 10], a1[maxn], a2[maxn], a3[maxn], c[maxn << 10], ls[maxn << 10], rs[maxn << 10];
void update(int& k, int l, int r, int p, int v) {
if (!k) k = ++tot; c[k] = max(c[k], v);
if (l == r) return;
int mid = (l + r) >> 1;
if (p <= mid) update(ls[k], l, mid, p, v);
else update(rs[k], mid + 1, r, p, v);
}
int query(int k, int l, int r, int p) {
if (!k) return 0;
if (r <= p) return c[k];
int mid = (l + r) >> 1, res = query(ls[k], l, mid, p);
if (p > mid) res = max(res, query(rs[k], mid + 1, r, p));
return res;
}
void updateval(int& k, int l, int r, int p1, int p2, int v) {
if (!k) k = ++tot; update(r2[k], 1, t3, p2, v);
if (r <= p1) return;
int mid = (l + r) >> 1;
if (p1 <= mid) updateval(ls[k], l, mid, p1, p2, v);
else updateval(rs[k], mid + 1, r, p1, p2, v);
}
int querymax(int k, int l, int r, int p1, int p2) {
if (!k) return 0;
if (r <= p1) return query(r2[k], 1, t3, p2);
int mid = (l + r) >> 1, res = querymax(ls[k], l, mid, p1, p2);
if (p1 > mid) res = max(res, querymax(rs[k], mid + 1, r, p1, p2));
return res;
}
void add(int x, int y, int z, int v) { for (; x <= t1; x += x & -x) updateval(r1[x], 1, t2, y, z, v); }
int getmax(int x, int y, int z) {
int res = 0; for (; x; x -= x & -x) res = max(res, querymax(r1[x], 1, t2, y, z));
return res;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
vector<tuple<int, int, int, int> > g(n);
for (auto& [x, y, z, w] : g) cin >> x >> y >> z >> w, a1[++t1] = y, a2[++t2] = z, a3[++t3] = w;
sort(g.begin(), g.end()); sort(a1 + 1, a1 + t1 + 1); sort(a2 + 1, a2 + t2 + 1); sort(a3 + 1, a3 + t3 + 1);
t1 = unique(a1 + 1, a1 + t1 + 1) - a1 - 1; t2 = unique(a2 + 1, a2 + t2 + 1) - a2 - 1; t3 = unique(a3 + 1, a3 + t3 + 1) - a3 - 1;
for (auto [x, y, z, w] : g) {
y = lower_bound(a1 + 1, a1 + t1 + 1, y) - a1; z = lower_bound(a2 + 1, a2 + t2 + 1, z) - a2; w = lower_bound(a3 + 1, a3 + t3 + 1, w) - a3;
int val = getmax(y, z, w); add(y, z, w, val + 1); ans = max(ans, val + 1);
} cout << ans << '\n';
return 0;
}
上一次尝试在8月15日,提交了30+次