#P1864. Nested Segments

Nested Segments

Nested Segments

题面翻译

在一条直线上有nn条线段,每条线段用(l,r)(l,r)表示,求每条线段包含多少条其他的线段。

题目描述

You are given n n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains.

输入格式

The first line contains a single integer n n ( 1<=n<=2105 1<=n<=2·10^{5} ) — the number of segments on a line.

Each of the next n n lines contains two integers li l_{i} and ri r_{i} ( -10^{9}<=l_{i}&lt;r_{i}<=10^{9} ) — the coordinates of the left and the right ends of the i i -th segment. It is guaranteed that there are no ends of some segments that coincide.

输出格式

Print n n lines. The j j -th of them should contain the only integer aj a_{j} — the number of segments contained in the j j -th segment.

样例 #1

样例输入 #1

4
1 8
2 3
4 7
5 6

样例输出 #1

3
0
1
0

样例 #2

样例输入 #2

3
3 4
1 5
2 6

样例输出 #2

0
1
1