#P5108. 仰望半月的夜空
仰望半月的夜空
Description
In the half-moon night sky, how many people’s feelings for each other are carried.
Xiyue knows that these feelings will gather into a string ().
Because the feelings are gathered in a way that is too complex, Xiyue hopes to refine all of them.
We define as follows: for the string , among all substrings of length , take the lexicographically smallest one; if there are multiple, take the one with the smallest left endpoint. Then is the value of that left endpoint.
For example, for , , , .
Xiyue will tell you the string . You only need to tell Xiyue ().
Input Format
The first line contains two parameters: and .
If , then the second line is a lowercase letter string of length .
Otherwise, the second line contains integers in .
Output Format
Output one line. The -th number表示 the value of .
26 11
remoonqaqac
8 10 8 8 2 2 2 2 2 2 1
26 11
txdydkwqaqa
9 9 9 5 5 5 5 3 3 1 1
10000000 17
9 9 8 2 4 4 3 5 3 1 9 2 6 0 8 1 7
14 14 14 14 10 10 10 10 4 4 4 4 4 4 3 2 1
Hint
The Constraints chart is missing QAQ.
The maximum range is .
Translated by ChatGPT 5
京公网安备 11011102002149号