Sphere Online Judge

SPOJ Problem Set (classical)

705. New Distinct Substrings

Problem code: SUBST1

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 <= 50000

Output

For each test case output one number saying the number of distinct substrings.

Example

Input:
2
CCCCC
ABABA

Output:
5
9

Added by:Hoang Hong Quan
Date:2006-01-18
Time limit:2s
Source limit:50000B
Languages:All except: CLOJ F# PERL 6 TECS
Resource:Base on a problem in ByteCode06

hide comments
2010-06-02 14:51:09 Leopoldo Taravilse
Do the strings contain the ' ' char?
2010-02-25 16:45:52 lccycc
length is <= 50000
I know.. but it's no the problem
I have open all arrays to 1100000

The problem is: it need long long for n and the output

Last edit: 2010-02-25 17:06:39
2010-02-25 16:40:53 [Trichromatic] XilinX
Read the problem statement (especially the input section) CAREFULLY
2010-02-25 16:25:32 lccycc
What's the difference between this problem and 694?
2009-11-30 14:05:48 Ray
The time limit should be loosen. For Python(Psyco), it is nearly impossible to AC by Suffix Array.
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.