#D1052. DQUERY
DQUERY
题目背景
https://www.luogu.com.cn/problem/SP3267
为了方便评测我造了纯随机的数据做成了本地题
题目描述
Given a sequence of n numbers a , a , ..., a and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the subsequence a , a , ..., a .
题面翻译
给出一个长度为n 的数列, , ,..., ,有q 个询问,每个询问给出数对,需要你给出 , ,..., 这一段中有多少不同的数字
输入格式
- Line 1: n (1 ≤ n ≤ 30000).
- Line 2: n numbers a , a , ..., a (1 ≤ a ≤ 10 ).
- Line 3: q (1 ≤ q ≤ 200000), the number of d-queries.
- In the next q lines, each line contains 2 numbers i, j representing a d-query (1 ≤ i ≤ j ≤ n).
输出格式
- For each d-query (i, j), print the number of distinct elements in the subsequence a , a , ..., a in a single line.
5
1 1 2 1 3
3
1 5
2 4
3 5
3
2
3