376 传统题

[P1117] [NOI2016] 优秀的拆分

时间限制
1500ms
内存限制
256MiB
登顶 / 尝试
1/ 1
难度
8
    上传者 标签NOI洛谷省选-后缀数组调和级数字符串

[P1117] [NOI2016] 优秀的拆分

Problem Statement (NOI2016 Day 1 Task 1 / Luogu P1117)

If a string can be split into the concatenation of four non-empty strings AABB (where A and B are non-empty strings, possibly A = B), then this splitting is called an excellent splitting. Given T strings S of lowercase English letters, for each string find the total number of excellent splittings across all substrings of S (identical substrings at different positions or different splittings of the same substring are counted separately).

Input: First line: integer T (1 <= T <= 10). Next T lines: each contains a lowercase string S (|S| <= 30000).

Output: T lines, each an integer representing the total number of excellent splittings.

Sample Input 1: 4 aabbbb cccccc aabaabaabaa bbaabaababaaba

Sample Output 1: 3 5 4 7