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
Input Specification
The first line of input contains a single integer,
The next line contains
Marks Awarded | Bounds on |
Additional Constraints |
---|---|---|
3 marks | For each |
|
4 marks | No additional constraints. | |
5 marks | If |
|
6 marks | Any number appears at most twice in the array. | |
7 marks | No additional constraints. |
Output Specification
The number of ways to partition the array into good contiguous subarrays, modulo
Sample Input 1
Copy
5
1 2 3 2 3
Sample Output 1
Copy
4
Explanation for Sample 1
There are four valid partitions of
, , , , , , , , ,
Sample Input 2
Copy
5
1 2 1 3 1
Sample Output 2
Copy
6
Comments