Grammy 有個獨特嘅見解關於字串。佢覺得一個字串係 正數 若且唯若佢字典序大過佢嘅反轉。
家下俾咗你一個字串,請你計出有幾多個連續子字串係符合 Grammy 嘅見解嘅正數。
輸入
唯一一行包含一個字串 $S$($1 \leq |S| \leq 200\,000$),由細楷英文字母組成。
輸出
輸出一個整數,表示 $S$ 入面正數子字串嘅數量。
示例
輸入 1
jjikkollp
輸出 1
4
輸入 2
pbpbppb
輸出 2
7
Grammy 有個獨特嘅見解關於字串。佢覺得一個字串係 正數 若且唯若佢字典序大過佢嘅反轉。
家下俾咗你一個字串,請你計出有幾多個連續子字串係符合 Grammy 嘅見解嘅正數。
唯一一行包含一個字串 $S$($1 \leq |S| \leq 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: