시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB86685.714%

문제

In an array containing only positive integers, we say an integer is heavy if it appears more than once in the array, and light otherwise.

An array is good if the integers in the array alternate between light and heavy.

Given an array $a_1, \dots , a_N$, count the number of ways to partition it into some number of contiguous subarrays such that each subarray, when considered as an array on its own, is good. As the answer may be large, output it modulo $1\, 000\, 003$.

입력

The first line of input contains a single integer, $N$.

The next line contains $N$ integers $a_1, \dots , a_N$ ($1 ≤ a_i ≤ N$).

출력

The number of ways to partition the array into good contiguous subarrays, modulo $1\, 000\, 003$.

서브태스크

Subtask Score Bounds on $N$ Additional constraints
1 3 $2 ≤ N ≤ 50\, 000$ For each $i$, $a_i ≤ 26$.
2 4 $2 ≤ N ≤ 5\, 000$ No additional constraints.
3 5 $2 ≤ N ≤ 500\, 000$ If $i$ is odd, then $a_i = 1$.
4 6 $2 ≤ N ≤ 500\, 000$ Any number appears at most twice in the array.
5 7 $2 ≤ N ≤ 500\, 000$ No additional constraints.

예제 입력 1

5
1 2 3 2 3

예제 출력 1

4

There are four valid partitions of $[1, 2, 3, 2, 3]$:

  • $[1], [2], [3], [2], [3]$
  • $[1], [2, 3, 2], [3]$
  • $[1], [2], [3, 2, 3]$
  • $[1, 2, 3, 2], [3]$

예제 입력 2

5
1 2 1 3 1

예제 출력 2

6

채점 및 기타 정보

  • 예제는 채점하지 않는다.