Palindrome Path 3
Time limit1sMemory limit256 MB
Count the paths from the top-left to the bottom-right corner moving only right or down whose letters form a palindrome, modulo 1000000007.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Matrix
- Solved
- No attempts yet
Problem
An farm grid () contains uppercase letters. A calf starts at and moves only right or down to reach . It gets lost whenever the letters on its path form a palindrome. Count how many palindrome paths exist, modulo .
Input
Line 1: . Next lines: the grid rows.
Output
Print the number of palindrome paths modulo .
Note
On the sample grid the answer is .