atcoder#AGC019B. [AGC019B] Reverse and Compare
[AGC019B] Reverse and Compare
Score : points
Problem Statement
You have a string consisting of lowercase English letters.
You can choose any two indices and such that and reverse substring .
You can perform this operation at most once.
How many different strings can you obtain?
Constraints
- consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the number of different strings you can obtain by reversing any substring in at most once.
aatt
5
You can obtain aatt
(don't do anything), atat
(reverse ), atta
(reverse ), ttaa
(reverse ) and taat
(reverse ).
xxxxxxxxxx
1
Whatever substring you reverse, you'll always get xxxxxxxxxx
.
abracadabra
44