#K42332. Count Unique Substrings

    ID: 27064 Type: Default 1000ms 256MiB

Count Unique Substrings

Count Unique Substrings

You are given a string s and your task is to count the number of unique substrings contained in s. A substring is defined as a contiguous sequence of characters within a string. Note that the empty substring is not considered. In mathematical terms, if n is the length of the string, the maximum number of substrings is \(\frac{n(n+1)}{2}\) when all substrings are distinct.

Your program will handle multiple test cases. For each test case, output the number of unique substrings on a new line.

inputFormat

The first line contains an integer T representing the number of test cases. Each of the following T lines contains a string s.

Example:

3
abc
aaa
abcd

outputFormat

For each test case, output a single line containing the count of unique substrings of the given string.

Example:

6
3
10
## sample
3
abc
aaa
abcd
6

3 10

</p>