Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- #include <set>
- #include <cstdio>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- struct val
- {
- int x, y;
- };
- val a[100050];
- int n, l, f[100050];
- map <int, int> m;
- bool cmp (val a, val b)
- {
- return a.y < b.y;
- }
- bool cmp2 (val a, val b)
- {
- if (a.x == b.x)
- {
- return a.y < b.y;
- }
- return a.x < b.x;
- }
- void add (int i)
- {
- while (i <= n)
- {
- f[i]++;
- i = i + i - (i & (i - 1));
- }
- }
- int sum (int i)
- {
- int ans = 0;
- while (i > 0)
- {
- ans += f[i];
- i = (i & (i - 1));
- }
- return ans;
- }
- int main()
- {
- freopen ("input.txt", "r", stdin);
- freopen ("output.txt", "w", stdout);
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- cin >> a[i].x >> a[i].y;
- }
- sort (a + 1, a + n + 1, cmp);
- l = 1;
- for (int i = 1; i <= n; i++)
- {
- if (m[a[i].y] == 0) m[a[i].y] = l;
- else l--;
- l++;
- }
- sort (a + 1, a + n + 1, cmp2);
- for (int i = 1; i <= n; i++)
- {
- add (a[i].y);
- }
- for (int i = 0; i < l; i++)
- {
- cout << sum (i) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement