PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000210. Đếm chuyến tàu nằm trọn trong đoạn (AtCoder Express 2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm chuyến tàu nằm trọn trong đoạn (AtCoder Express 2)
AtCoder Express 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are cities numbered 1 through on a railway. Each of the trains serves an interval , possibly with equal endpoints. For each of the queries , count trains whose entire route is contained in it: . Trains with identical routes count separately.
Input
The first line contains . The next lines contain . The following lines contain .
Output
Print lines, one count per query.
Subtasks
- Subtask 1 (20 points): ; ; ; ; .
- Subtask 2 (30 points): ; ; ; ; ; .
- Subtask 3 (50 points): ; ; ; ; .
Example 1
Input
2 3 1
1 1
1 2
2 2
1 2
Output
3
Explanation
All three routes lie in [1,2].
Example 2
Input
10 3 2
1 5
2 8
7 10
1 7
3 10
Output
1
1
Explanation
The first query contains only train 1; the second contains only train 3.
Example 3
Input
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10
Output
7
9
10
6
8
9
6
7
8
10
Explanation
The two [4,7] trains are counted separately. [1,10] contains all ten trains.