题库练习 Diverse Substrings
← 上一题 下一题 →

A9308 | Diverse Substrings

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

String diversity is the number of symbols that occur in the string at least once. Diversity of $s$ will be denoted by $d(s)$ . For example , $d$ ("aaa")=1, $d$ ("abacaba")=3.

Given a string $s$ , consisting of lowercase Latin letters. Consider all its substrings. Obviously, any substring diversity is a number from 1 to $d(s)$ . Find statistics about substrings diversity: for each $k$ from 1 to $d(s)$ , find how many substrings of $s$ has a diversity of exactly $k$ .

输入格式

The input consists of a single line containing $s$ . It contains only lowercase Latin letters, the length of $s$ is from 1 to $3·10^{5}$ .

输出格式

Print to the first line the value $d(s)$ . Print sequence $t_{1},t_{2},...,t_{d(s)}$ to the following lines, where $t_{i}$ is the number of substrings of $s$ having diversity of exactly $i$ .

输入输出样例

输入 #1
abca
输出 #1
3
4
3
3
输入 #2
aabacaabbad
输出 #2
4
14
19
28
5
C++ 编辑器
输入
输出