SPOJ Problem Set (classical)694. Distinct SubstringsProblem code: DISUBSTR |
Given a string, we need to find the total number of its distinct substrings.
Input
T- number of test cases. T<=20;
Each test case consists of one string, whose length is <= 1000
Output
For each test case output one number saying the number of distinct substrings.
Example
Sample Input:
2
CCCCC
ABABA
Sample Output:
5
9
Explanation for the testcase with string ABABA:
len=1 : A,B
len=2 : AB,BA
len=3 : ABA,BAB
len=4 : ABAB,BABA
len=5 : ABABA
Thus, total number of distinct substrings is 9.
| Added by: | Prasanna |
| Date: | 2006-01-13 |
| Time limit: | 1s |
| Source limit: | 50000B |
| Languages: | All except: PERL 6 |
| Resource: |
|
本文介绍了一个计算字符串不同子串数量的问题,并提供了一种解决方案,通过后缀数组和高度数组计算出所有可能的不同子串数目。
2899

被折叠的 条评论
为什么被折叠?



