#C3273. Longest Palindromic Substring Length

    ID: 46682 Type: Default 1000ms 256MiB

Longest Palindromic Substring Length

Longest Palindromic Substring Length

Vasya has a unique ability to identify patterns within strings. One of his favorite tasks is to find the longest palindromic substring in a given string. A palindrome is a string that reads the same forwards and backwards. In mathematical terms, a string \( s \) is a palindrome if \( s = s^R \) where \( s^R \) denotes the reversal of \( s \).

Your task is to help Vasya by writing a program that, given multiple test cases, determines the length of the longest palindromic substring for each input string.

For example, given the string "racecar", the longest palindromic substring is "racecar" with a length of 7, and for the string "hello", the longest palindromic substring is "ll" with a length of 2.

inputFormat

The input is read from standard input and has the following format:

  • The first line contains an integer \( t \) (1 \( \leq t \leq 100 \)), representing the number of test cases.
  • Each of the next \( t \) lines contains a string \( s \) (0 \( \leq |s| \leq 1000 \)). Each string consists only of English letters. (A blank line represents an empty string.)

outputFormat

For each test case, output a single integer on a new line representing the length of the longest palindromic substring in the corresponding string.

## sample
1
racecar
7

</p>