TopCoder

Thumb tumblr nlxw0sxc2d1unbsixo1 540
Morty
wubbalubbadubdub

User's AC Ratio

100.0% (4/4)

Submission's AC Ratio

83.3% (5/6)

Tags

Description

有一天強大的tourist出了一題有關字串的題目,大家原本都以為那是一題很簡單的題目,誰知道卻....

題目的內容是這樣的
給你一個字串,你可以將任意一段子字串反轉,但只能反轉一次,問你最多可能產生幾種相異的字串

題目看似簡單,卻藏著大大的殺機,請你小心翼翼的將這題解出來吧

Input Format

一行長度為$N (N \leq 10^ 6)$且僅包含小寫英文字母的字串

Output Format

請輸出方法數

Sample Input

aatt

Sample Output

5

Hints

子任務(測資)額外限制分數
1(0~4)$N \le 10 ^ 3$40
2(5~9)60



範例測資中,可生成aatt. atat. atta. taat, ttaa

Problem Source

Problem Set By oToToT
Adapted form AtCoder Grand Contest 19 pB

Subtasks

For Testdata: 0 ~ 4, Score: 40
For Testdata: 5 ~ 9, Score: 60
No. Time Limit (ms) Memory Limit (KiB) Output Limit (KiB)
0 1000 65536 65536
1 1000 65536 65536
2 1000 65536 65536
3 1000 65536 65536
4 1000 65536 65536
5 1000 65536 65536
6 1000 65536 65536
7 1000 65536 65536
8 1000 65536 65536
9 1000 65536 65536