arr of length length whose elements are integers from 1 to top. Call a neighbouring pair (positions i and i + 1) marked if arr[i] · arr[i + 1] − arr[i] − arr[i + 1] is even.
Return how many arrays have exactly links marked pairs. The answer can be large, so return it modulo 10⁹ + 7.length=2, top=3, links=1 → 1
Among pairs of numbers from 1 to 3, only [2, 2] works: 2 · 2 − 2 − 2 = 0, which is even.
length=3, top=2, links=0 → 5
5 of the 8 arrays work: all except [2, 2, 1], [1, 2, 2] and [2, 2, 2].
length=1, top=6, links=0 → 6
A one-element array has no neighbour pairs, so any of the 6 numbers works.
length ≤ 750links ≤ length − 1top ≤ 1000length=2, top=3, links=1
1
Run checks the first 3 tests in your browser. Submit checks all 58 tests on the server, hidden ones included.