Within 1 - MarisaOJ: Marisa Online Judge

Within 1

Time limit: 1000 ms
Memory limit: 256 MB
Given $n$ line segments on the number line, where the $i$-th segment starts at $l_i$ and ends at $r_i$. Segment $j$ is said to be within segment $i$ if $l_i \leq l_j \leq r_j \leq r_i$. For each line segment, count the number of line segments it is contained within (excluding itself). ### Input - The first line contains an integer $n$. - The next $n$ lines, each line contains two integers $l_i$ and $r_i$. ### Output - Print $n$ integers, where the $i$-th integer represents the number of line segments segment $i$ is contained within. ### Constraints - $1 \le n \le 10^5$. - $1 \le l_i \le r_i \le 10^5$. ### Example Input ``` 3 1 5 2 3 1 4 ``` Output ``` 0 2 1 ```