#P17451. 文回文 / Emordnilap

    ID: 19964 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>字符串2026高校校赛

文回文 / Emordnilap

Problem Description

Given a string ss of length nn, with indices starting from 11. For each 1≤i≤n1 \le i \le n, if the substring of length 2r+12r+1 centered at ii is a palindrome, then the non-negative integer rr is called a palindrome radius of center ii.

For each center ii, 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 TT (1≤T≤1061 \le T \le 10^6), which is the number of test cases.

Each test case consists of one line containing a non-empty string ss. It is guaranteed that ss contains only lowercase English letters.

It is guaranteed that ∑∣s∣≤106\sum \lvert s \rvert \le 10^6.

Output Format

Output TT lines. For each line, output ∣s∣\lvert s \rvert integers, where the ii-th integer is the answer for center ii.

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 33: b, aba, and cabac. The lexicographically smallest one is aba, with radius 11.

Translated by ChatGPT 5