6884.Distinct Substrings

Time Limit: 1s Memory Limit: 512MB

Count the number of distinct substrings that appear in a string.

Input Format(From the terminal/stdin)

The only input line has a string of length $n$ that consists of characters a–z.

  • $1 \le n \le 10^5$

Output Format(To the terminal/stdout)

Print one integer: the number of substrings.

Sample Input

Copy
abaa
    \n

Sample Output

Copy
8
 \n

the substrings are a , b , aa , ab , ba , aba , baa and abaa .

Source: CSES, String Algorithms, 2105

Submit

请先 登录

© 2025 FAQs