#P16448. [XJTUPC 2026] Triple Mirror: The Harmony of Repetition
[XJTUPC 2026] Triple Mirror: The Harmony of Repetition
Background
:::epigraph[------ Palindrom] Blankness is the only language that never lies. :::
Problem Description
You are playing a game called “Mirror Fragments”. In this game, you travel through an ancient ruin made of mirrors. The inscriptions in the ruin change in strange ways inside the mirrors.
You once observed that after a character sequence is reflected by a mirror, what you see looks like it is “unfolded”, and every character appears twice. For example, the sequence appears in the mirror as . If you look from the side and see both the real object outside the mirror and the virtual image in the mirror at the same time, they overlap in order, forming . This overlapped whole is the complete mapping of the sequence.
You are very interested in this mapping. Now you are given a string of length . Please count how many non-empty substrings (where ) can be an image of such a mapping. Specifically, a substring of length must satisfy the following conditions:
- is a multiple of .
- Let . Then for all , we have .
In other words, must be of the form:
$$a_1a_1a_2a_2a_3a_3\cdots a_{k}a_{k}a_{k}a_{k-1}a_{k-2}\cdots a_1$$where is some character sequence.
Note that for two substrings and , they are considered two different substrings and should be counted twice if and only if or .
Input Format
The input consists of one line containing only a string (the length satisfies ). It is guaranteed that consists only of lowercase Latin letters $\texttt{a}, \texttt{b}, \texttt{c}, \cdots, \texttt{z}$.
Output Format
Output one line containing one integer, the number of substrings that satisfy the conditions.
aaaaaa
5
aaaaaabbbcccccc
11
Hint
Translated by ChatGPT 5