#P17451. 文回文 / Emordnilap
文回文 / Emordnilap
Problem Description
Given a string of length , with indices starting from . For each , if the substring of length centered at is a palindrome, then the non-negative integer is called a palindrome radius of center .
For each center , find the palindrome radius such that the corresponding palindromic substring is lexicographically smallest.
Input Format
This problem has multiple test cases.
The first line contains an integer (), which is the number of test cases.
Each test case consists of one line containing a non-empty string . It is guaranteed that contains only lowercase English letters.
It is guaranteed that .
Output Format
Output lines. For each line, output integers, where the -th integer is the answer for center .
2
cabacbc
a
0 0 1 0 0 0 0
0
Hint
In the first test case of the sample, there are three palindromic substrings centered at : b, aba, and cabac. The lexicographically smallest one is aba, with radius .
Translated by ChatGPT 5