PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000076. Truy vấn hai miền giá trị (Range query)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vấn hai miền giá trị (Range query)
Range query
Source: MarisaOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Each query requests two counts among positions whose values satisfy : (1) the number of positions; (2) the number of distinct values.
Input
Read , the array and quadruples .
Output
Print matching_positions distinct_matching_values for each query.
Subtasks
- Subtask 1 (10 points): , . ; ; .
- Subtask 2 (20 points): , . ; ; .
- Subtask 3 (30 points): , . ; ; .
- Subtask 4 (40 points): , . ; ; .
Examples
Input
3 4
1 2 2
1 2 1 3
1 2 1 1
1 3 1 3
2 3 2 3
Output
2 2
1 1
3 2
2 1
Explanation
The array is . The first query selects two positions with values 1 and 2, so both counts are 2. In the last query, positions 2 and 3 contain two copies of value 2: two positions but only one distinct value.