408005: GYM102961 S Nested Ranges Count
Memory Limit:256 MB
Time Limit:0 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
S. Nested Ranges Counttime limit per test2.0 smemory limit per test256 megabytesinputstandard inputoutputstandard output
Given $$$n$$$ ranges, your task is to count for each range how many other ranges it contains and how many other ranges contain it.
Range $$$[a,b]$$$ contains range $$$[c,d]$$$ if $$$a\le c$$$ and $$$d\le b$$$.
InputThe first input line has an integer $$$n$$$: the number of ranges.
After this, there are $$$n$$$ lines that describe the ranges. Each line has two integers $$$x$$$ and $$$y$$$: the range is $$$[x,y]$$$.
You may assume that no range appears more than once in the input.
Constraints:
- $$$1 \le n \le 2\cdot 10^5$$$
- $$$1 \le x < y \le 10^9$$$
First print a line that describes for each range (in the input order) how many other ranges it contains.
Then print a line that describes for each range (in the input order) how many other ranges contain it.
ExampleInput4 1 6 2 4 4 8 3 6Output
2 0 0 0 0 1 0 1