Prof. Pang's sequence
Time limit3sMemory limit1024 MB
For each query [l, r], count the subarrays a_i..a_j inside it whose number of distinct values is odd.
- Level
Hard10 of 10
- Topics
- Divide and conquer, Array, Hash map, Dynamic programming
- Solved
- No attempts yet
Problem
Prof. Pang is given a fixed sequence and queries.
Each query gives two integers and with . For each query, count the pairs of integers with such that the number of distinct integers in is odd.
Input
The first line contains one integer ().
The second line contains integers (), separated by single spaces.
The next line contains one integer ().
Each of the next lines contains two integers and (), separated by a single space.
Output
For each query, output the answer on its own line.