Problem G
Palindromic Word Search
Given a rectangular grid of uppercase letters, find a rectangular region of the grid of maximum possible area such that there is a horizontal palindrome spanning some row of the rectangular region and a vertical palindrome spanning some column of the rectangular region. Recall a palindrome is a string that equals its own reversal.
![\includegraphics[width=0.8\textwidth ]{palindromic.pdf}](/problems/palindromicwordsearch/file/statement/en/img-0001.png)
Input
The first line contains two integers
Output
Output a single integer
Sample Input 1 | Sample Output 1 |
---|---|
4 5 APPLE BOBBY KAYAK REBEL |
15 |
Sample Input 2 | Sample Output 2 |
---|---|
2 6 ABCCDE PRCDEE |
4 |
Sample Input 3 | Sample Output 3 |
---|---|
4 6 BANANA BERGEN CANNOT FELLOW |
15 |