Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "HCN"
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 1e2 + 5;
- int n, f[N];
- struct Rectangle
- {
- int x, y, z, t;
- bool operator<(const Rectangle &a) const
- {
- return x < a.x || (x == a.x && (y < a.y || (y == a.y && (z < a.z || (z == a.z && t < a.t)))));
- }
- } a[N];
- void Read()
- {
- cin >> n;
- for (int i = 1; i <= n; ++i)
- cin >> a[i].x >> a[i].y >> a[i].z >> a[i].t;
- }
- void Solve()
- {
- sort(a + 1, a + n + 1);
- // Sắp các hình chữ nhật tăng theo hoành độ và tung độ để duyệt tuần tự từ đầu tới cuối và cập nhật đáp án
- for (int i = 1; i <= n; ++i)
- {
- f[i] = 1;
- for (int j = 1; j < i; ++j)
- if (a[i].x >= a[j].x && a[i].y >= a[j].x && a[i].z <= a[j].z && a[i].t <= a[j].t)
- f[i] = max(f[i], f[j] + 1);
- }
- cout << *max_element(f + 1, f + n + 1);
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement