第一行一个正整数 T,表示数据组数。接下来 T 行,每组数据一行,为字符串 S。
1 <= |S| <= 100000, T <= 10
7
c
aaaab
bbaaaacc
ababa
abba
baab
aaabacdbbdcabaaaaaaaaaaaab
1
4
7
5
3
3
18
//{} -> c,代价为 1
{} -> aa -> aaaa -> aaaab,代价为 2 + 1 + 1 = 4
{} -> aa -> aaaa -> aaaacc -> bbaaaac,代价为 2 + 1 + 2 + 2 = 7
{} -> ababa,代价为 5
{} -> ab -> abba,代价为 2 + 1 = 3
{} -> ab -> baab,代价为 2 + 1 = 3
{} -> aaa -> aaaaaa -> baaaaaa -> baaaaaaaaaaaab -> aaabacdbbdcabaaaaaaaaaaaab,
代价为 3 + 1 + 1 + 1 + 12 = 18