#P4065. [JXOI2017] 颜色
[JXOI2017] 颜色
Description
Kelian has a sequence of positive integers of length , denoted by , where equal integers represent the same color.
Kelian thinks the sequence is too long, so she decides to choose some colors and delete all positions of those colors.
Deleting color is defined as removing from the sequence all positions such that .
However, sometimes after deletions, the entire sequence breaks into several segments. Kelian does not like that, so she wants to know how many ways to delete colors will make the remaining sequence non-empty and contiguous.
For example, for the color sequence , after deleting color , the sequence becomes two segments and , which does not satisfy the requirement. After deleting color , the sequence becomes , which satisfies the requirement.
Two schemes are different if and only if there exists at least one color that is deleted in exactly one of them.
Input Format
The first line contains an integer , the number of test cases.
For each test case, the first line contains an integer , the length of the sequence; the second line contains integers describing the color sequence.
Output Format
For each test case, output a single integer denoting the answer.
1
5
1 3 2 4 3
6
Hint
The valid deletion schemes are $\{1\}, \{1, 3\}, \{1, 2, 3\}, \{1, 3, 4\}, \{2, 3, 4\}, \varnothing$.
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号