7018.Distinct Values Splits

Time Limit: 1s Memory Limit: 512MB

You are given an array of $n$ integers. Your task is to count the number of ways to split the array into continuous segments such that all segments consists of distinct values.

Input Format(From the terminal/stdin)

The first line has an integers $n$ : the size of the array.

The next line has $n$ integers $x_1, x_2,\dots, x_n$ : the contents of the array.

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le x_i \le 10^9$

Output Format(To the terminal/stdout)

Print one integer: the answer to the problem modulo $10^9 + 7$ .

Sample Input

Copy
4
1 2 1 3
 \n
 · · · \n

Sample Output

Copy
6
 \n
  • $[1], [2], [1], [3]$
  • $[1], [2], [1, 3]$
  • $[1], [2, 1], [3]$
  • $[1], [2, 1, 3]$
  • $[1, 2], [1], [3]$
  • $[1, 2], [1, 3]$
Source: CSES, Additional Problems I, 3190

Submit

请先 登录

© 2025 FAQs