#K1521. Distinct Elements in Subarrays

    ID: 24306 Type: Default 1000ms 256MiB

Distinct Elements in Subarrays

Distinct Elements in Subarrays

Given (T) test cases, each test case consists of an integer (n) and an array of (n) integers. For each test case, you are required to compute an array (res) of length (n) where the (i)-th element represents the number of distinct integers in the prefix of the array from the first element up to the (i)-th element. In other words, for each index (i) (1-indexed), (res[i] = |{a_1, a_2, \ldots, a_i}|).

Your task is to process each test case and output the corresponding array of counts for each test case. The input will be read from standard input (stdin) and the output should be printed on standard output (stdout).

inputFormat

The first line of input contains a single integer (T) denoting the number of test cases. For each test case, the first line contains an integer (n) denoting the size of the array. The next line contains (n) space-separated integers representing the array elements.

outputFormat

For each test case, output a single line containing (n) space-separated integers, where the (i)-th integer is the number of distinct elements in the subarray from the beginning to the (i)-th element.## sample

1
5
1 2 1 3 2
1 2 2 3 3

</p>