AtCoder Grand Contest 019
翻译中…
Problem Statement
翻译中…
You have a string $A = A_1 A_2 ... A_n$ consisting of lowercase English letters.
翻译中…
You can choose any two indices $i$ and $j$ such that $1 \leq i \leq j \leq n$ and reverse substring $A_i A_{i+1} ... A_j$.
翻译中…
You can perform this operation at most once.
翻译中…
How many different strings can you obtain?
翻译中…
Constraints
翻译中…
$1 \leq |A| \leq 200,000$$A$consists of lowercase English letters.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
A
翻译中…
Output
翻译中…
Print the number of different strings you can obtain by reversing any substring in $A$ at most once.
翻译中…
样例
Input #1
aatt
Output #1
5
You can obtain `aatt` (don't do anything), `atat` (reverse $A[2..3]$), `atta` (reverse $A[2..4]$), `ttaa` (reverse $A[1..4]$) and `taat` (reverse $A[1..3]$).
Input #2
xxxxxxxxxx
Output #2
1
Whatever substring you reverse, you'll always get `xxxxxxxxxx`.
Input #3
abracadabra
Output #3
44
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。