영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
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 ≤ c and d ≤ b.
Input
The 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.
Output
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.
Constraints
- 1 ≤ n ≤ 2 · 10^5
- 1 ≤ x < y ≤ 10^9
예제
예제 1
4 1 6 2 4 4 8 3 6
2 0 0 0 0 1 0 1