#abc285b. B - Longest Uncommon Prefix
B - Longest Uncommon Prefix
Score : points
问题描述
你将得到一个长度为 的由小写英文字母组成的字符串 。其中,第 个()字符记为 。
对于每个 ,找出满足以下所有条件的最大非负整数 :
- ,且
- 对于所有满足 的整数 ,均有 。
注意: 总是满足上述条件。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string of length consisting of lowercase English letters. The -th character of is .
For each , find the maximum non-negative integer that satisfies all of the following conditions:
- , and
- for all integers such that , it holds that .
Note that always satisfies the conditions.
Constraints
- is an integer such that .
- is a string of length consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer as an integer when .
Sample Input 1
6
abcbac
Sample Output 1
5
1
2
0
1
In this input, abcbac
.
- When , we have , and , so the maximum value is .
- When , we have but , so the maximum value is .
- When , we have and but , so the maximum value is .
- When , we have , so the maximum value is .
- When , we have , so the maximum value is .
update @ 2024/3/10 11:55:10