luogu#P4888. 三去矩阵
三去矩阵
Problem Description
Now Little Y has an square letter matrix. He wants to make queries. For each query, find the maximum length of a palindrome string centered at that lies on a single horizontal or vertical line.
Input Format
The first line contains two integers , representing the side length of the matrix and the number of queries.
The next lines each contain letters, representing the letters in the matrix.
The next lines each contain two integers , representing the -th query: ask for the maximum length of a palindrome centered at that lies on a single straight line in the matrix.
Output Format
Output lines. The -th line should be the answer to the -th query.
5 5
abcba
bcdcb
cdedc
bcdcb
abcba
1 1
1 2
1 3
2 3
3 3
1
1
5
5
5
Hint
For of the testdata, .
Another of the testdata has .
Another of the testdata has a letter matrix that is centrally symmetric, vertically symmetric, horizontally symmetric, and diagonally symmetric.
For of the testdata, , and the letters are lowercase only.
Translated by ChatGPT 5