#P8715. [蓝桥杯 2020 省 AB2] 子串分值
[蓝桥杯 2020 省 AB2] 子串分值
Problem Description
For a string , we define its value as the number of characters that appear exactly once in . For example, $f\left({ }^{\prime \prime} \mathrm{aba}{ }^{\prime \prime}\right)=1$, $f\left({ }^{\prime \prime} \mathrm{abc}{ }^{\prime \prime}\right)=3$, and $f\left({ }^{\prime \prime} \mathrm{aaa} \mathrm{a}^{\prime \prime}\right)=0$.
Now given a string (with length ), please compute the sum of over all non-empty substrings .
Input Format
Input one line containing a string consisting of lowercase letters.
Output Format
Output an integer representing the answer.
ababc
21
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For all testdata, .
Lanqiao Cup 2020, second round provincial contest, Group A Problem H (Group B Problem H).
Translated by ChatGPT 5