PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000054. Đếm các đoạn nằm bên trong (Nested Segments)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm các đoạn nằm bên trong (Nested Segments)
Nested Segments
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are segments whose endpoints are all distinct. For each segment , count other segments entirely inside it, so and .
Input
The first line contains , followed by lines of endpoints .
Output
Print lines: the count of other segments inside each original segment.
Subtasks
- Subtask 1 (20 points): ; ; all endpoints are distinct.
- Subtask 2 (30 points): ; ; all endpoints are distinct.
- Subtask 3 (50 points): ; ; all endpoints are distinct.
Examples
Input
4
1 8
2 3
4 7
5 6
Output
3
0
1
0
Explanation
The segment [1,8] contains all three others; [4,7] contains [5,6]. The remaining two contain none.