atcoder#ARC159F. [ARC159F] Good Division
[ARC159F] Good Division
Score : points
Problem Statement
A sequence is called good when the following holds.
- can be emptied by repeating the following operation zero or more times.- Delete two adjacent elements and of such that .
- Delete two adjacent elements and of such that .
You are given a sequence with elements: . Among the ways to divide into one or more contiguous subsequences, how many are such that all those contiguous subsequences are good? Find the count modulo .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
3
1 1 2 3 4 5
2
The following two divisions satisfy the condition.
1
1 2
1
1
1 1
0
12
4 2 17 12 18 15 17 4 22 6 9 20 21 16 23 16 13 2 20 15 16 3 7 15
2048