#P4840. P哥旋转

P哥旋转

Description

P-bro has learned a new method for string processing: rotation.

A “rotation” is an operation like this: remove the last character of the original string, then add it to the very front, obtaining a new string.

P-bro can perform the “rotation” operation infinitely many times, in order to make the number of essentially different palindromic substrings in the resulting new string as large as possible.

Two palindromic strings are essentially different if and only if their lengths are different, or there exists at least one position where the characters are different.

Now P-bro has obtained a string SS. Please help P-bro achieve his goal through “rotation” operations (i.e., the bolded part above), and output the number of different palindromic substrings in the new string.

Input Format

The input consists of one line, which is the string SS, guaranteed to contain only lowercase English letters.

Output Format

Output one integer, representing the answer.

ioimoio

7

fcfcfcfcfczxqprvvlpstpasxvpyyhaejxehdlhckmwmibsjwqbmfzlwpjqjghmlxunefabkpryqxbkqridpqrzemvfcfcfcfcfc
47

Hint

Let nn be the length of string SS.

  • For the first 20%20\% of the testdata, n100n \le 100.
  • For the first 40%40\% of the testdata, n2000n \le 2000.
  • For another 10%10\% of the testdata, it is guaranteed that you can obtain the correct answer without performing any rotation.
  • For 100%100\% of the testdata, n1.5×106n \le 1.5\times 10^6.

In addition, for the last 50%50\% of the testdata, it is guaranteed that the length of the non-random part of string SS does not exceed 50005000.

Note: This problem uses subtask scoring. The first 50%50\% of the testdata is subtask#1, and this subtask uses additive scoring (you may consider it as traditional scoring). The last 50%50\% of the testdata is subtask#2, and this subtask uses min\min scoring (that is, if you get even one test wrong, you get 00 points for the last 5050 points).

Translated by ChatGPT 5