Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector<vector<int> >a(n, vector<int>(2));
- for (int i = 0; i < n; i++)
- cin >> a[i][0] >> a[i][1];
- for(int i = 0; i < n; i++)
- for(int x = 0; x < n; x++)
- {
- if (a[i][0] <= a[x][0] && a[i][1] >= a[x][1] && i != x)
- { // один отрезок прннадлежит другому
- a[x][0] = a[a.size() - 1][0];
- a[x][1] = a[a.size() - 1][1];
- a.pop_back();
- }
- else if (a[i][0] < a[x][0] && a[i][1] < a[x][1])
- {// отрезок пересекает другой
- a[i][1] = a[x][1];
- a[x][0] = a[a.size() - 1][0];
- a[x][1] = a[a.size() - 1][1];
- a.pop_back();
- }
- }
- cout << a.size() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement