PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000010. Đếm màu khác nhau trong đoạn (Range Set Query)
HỌC THEO LỘ TRÌNH
3 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm màu khác nhau trong đoạn (Range Set Query)
Range Set Query
Source: AtCoder Version: Phuoc Hung OJ Extended
Problem Statement
There are colored balls in a row; ball has color . For each inclusive query , count the number of different colors present in that subarray. No colors change.
Input
The first line contains . The second line contains colors . The next lines each contain .
Output
Print lines, one answer per query in the original order.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
4 3
1 2 1 3
1 3
2 4
3 3
Output
2
3
1
Explanation
Query contains just one ball and therefore one color.