#P6114. 【模板】Lyndon 分解
【模板】Lyndon 分解
Problem Description
This is a template problem.
Given a string consisting of lowercase English letters, split it into several parts , such that each is a Lyndon Word, and . Output the positions of the right endpoints of the lengths of the strings from to . The positions are numbered from to .
A string is a if and only if is the smallest string among all its suffixes.
To reduce the output size, you only need to output the XOR of all right endpoints.
Input Format
One line containing a string of length , consisting only of lowercase English letters.
Output Format
One line containing an integer, representing the XOR of all right endpoints.
ababa
3
bbababaabaaabaaaab
23
Hint
The answer for the first sample is 2 4 5.
The answer for the second sample is 1 2 4 6 9 13 18.
- For of the testdata, is guaranteed.
- For of the testdata, is guaranteed.
Translated by ChatGPT 5