Time Limit: 3 second(s) | Memory Limit: 64 MB |
Given an array of N integers indexed from 1 to N, and q queries, each in the form i j, you have to find the number of distinct integers from index i to j (inclusive).
Input starts with an integer T (≤ 5), denoting the number of test cases.
The first line of a case is a blank line. The next line contains two integers N (1 ≤ N ≤ 10^{5}), q (1 ≤ q ≤ 50000). The next line contains N space separated integers forming the array. There integers range in [0, 10^{5}].
Each of the next q lines will contain a query which is in the form i j (1 ≤ i ≤ j ≤ N).
For each test case, print the case number in a single line. Then for each query you have to print a line containing number of distinct integers from index i to j.
Sample Input |
Output for Sample Input |
1
8 5 1 1 1 2 3 5 1 2 1 8 2 3 3 6 4 5 4 8 |
Case 1: 4 1 4 2 4 |
Dataset is huge. Use faster I/O methods.
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |