Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <algorithm>
- #include <set>
- #include <queue>
- using namespace std;
- struct sz
- {
- int w, h, k;
- sz():w(0), h(0), k(0){}
- sz(int _w, int _h, int _k) :w(_w), h(_h), k(_k) {}
- };
- bool operator< (sz x, sz y)
- {
- return x.w < y.w && x.h < y.h;
- }
- bool operator==(sz x, sz y)
- {
- return x.w == y.w && x.h == y.h;
- }
- vector<sz> a;
- vector<int> d;
- vector<pair<int, int> > f;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n, w, h;
- cin >> n >> w >> h;
- int ww, hh;
- for (int i = 0; i < n; i++)
- {
- cin >> ww >> hh;
- if (ww <= w || hh <= h)
- continue;
- a.push_back(sz(ww, hh, i + 1));
- }
- if (a.size() < 2)
- {
- cout << a.size() << endl;
- for (int i = a.size() - 1; i >= 0; i--)
- cout << a[i].k << " ";
- return 0;
- }
- sort(a.begin(), a.end());
- f.resize(a.size(), make_pair(1, -1));
- for (int i = 1; i < a.size(); i++)
- for (int j = 0; j < i; j++)
- {
- if (a[j] < a[i] && f[i].first < f[j].first + 1)
- f[i] = make_pair(f[j].first + 1, j);
- }
- int ans = 0;
- int r = 0;
- sz t;
- for (int i = 0; i < a.size(); i++)
- {
- if (f[i].first > ans)
- {
- ans = f[i].first;
- t = a[i];
- r = i;
- }
- }
- while (f[r].second != -1)
- {
- d.push_back(a[r].k);
- r = f[r].second;
- }
- d.push_back(a[r].k);
- cout << d.size() << endl;
- for (int i = d.size() - 1; i >= 0; i--)
- cout << d[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement