Grammy 对字符串有着独特的见解。她认为一个字符串是“正向的”(positive),当且仅当它在字典序上大于它的反转。
现在给定一个字符串,请找出它有多少个连续子串是根据 Grammy 的见解定义的“正向”字符串。
输入格式
输入包含一行字符串 $S$ ($1 \le |S| \le 200\,000$),仅由小写英文字母组成。
输出格式
输出一个整数,表示 $S$ 中“正向”子串的数量。
样例
输入 1
jjikkollp
输出 1
4
输入 2
pbpbppb
输出 2
7
Grammy 对字符串有着独特的见解。她认为一个字符串是“正向的”(positive),当且仅当它在字典序上大于它的反转。
现在给定一个字符串,请找出它有多少个连续子串是根据 Grammy 的见解定义的“正向”字符串。
输入包含一行字符串 $S$ ($1 \le |S| \le 200\,000$),仅由小写英文字母组成。
输出一个整数,表示 $S$ 中“正向”子串的数量。
jjikkollp
4
pbpbppb
7
The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.
This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.
If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.
Guidelines: