PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000055. Đếm quan hệ bao nhau giữa các đoạn (Nested Ranges Count)
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 quan hệ bao nhau giữa các đoạn (Nested Ranges Count)
Nested Ranges Count
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
You are given distinct inclusive ranges. Range contains if and . For each range, count the other ranges it contains and those that contain it, preserving input order.
Input
The first line is , followed by inclusive ranges .
Output
Print contained-range counts, followed by containing-range counts.
Subtasks
- Subtask 1 (20 points): ; ; no two ranges are identical.
- Subtask 2 (30 points): ; ; no two ranges are identical.
- Subtask 3 (50 points): ; ; no two ranges are identical.
Examples
Input
4
1 6
2 4
4 8
3 6
Output
2 0 0 0
0 1 0 1
Explanation
[1,6] contains [2,4] and [3,6]; those two ranges are each contained once, while [4,8] participates in no containment relation.