#C10621. Distinct Crystal Identifiers
Distinct Crystal Identifiers
Distinct Crystal Identifiers
You are given a list of n crystals, each with a unique identifier. Your task is to process q queries. Each query provides two indices l and r (1-indexed), and you must determine the number of distinct crystal identifiers in the subarray from index l to r.
The subarray for a query is defined as the sequence \( a_l, a_{l+1}, \dots, a_r \), where \( a_i \) is the identifier of the i-th crystal. Your solution should process the input from standard input (stdin) and output the results to standard output (stdout), one result per query.
inputFormat
The input is read from standard input in the following format:
- The first line contains an integer \( n \) denoting the number of crystals.
- The second line contains \( n \) space-separated integers representing the crystal identifiers.
- The third line contains an integer \( q \) denoting the number of queries.
- Each of the next \( q \) lines contains two space-separated integers \( l \) and \( r \) representing the starting and ending indices (1-indexed) of the subarray.
outputFormat
For each query, output a single integer on a separate line representing the number of distinct crystal identifiers in the subarray from index \( l \) to \( r \).
## sample5
1 2 1 3 2
3
1 3
2 4
1 5
2
3
3
</p>