#C3065. Distinct Substring Count

    ID: 46451 Type: Default 1000ms 256MiB

Distinct Substring Count

Distinct Substring Count

Given a string s consisting of L lowercase English letters, your task is to compute the number of distinct non-empty substrings of s modulo \(10^9+7\). A substring is a contiguous sequence of characters within a string.

Note: The distinct substring count includes all unique substrings that can be formed by taking continuous segments of the original string. For example, if s = "abcd", the distinct substrings are: "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd", and the answer is 10.

The formula for the modulo operation is given by: \[ \text{result} = \left( \text{number of distinct substrings} \right) \bmod \left(10^9+7\right) \]

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  1. The first line contains a single integer L representing the length of the string.
  2. The second line contains the string s, which is composed of L lowercase English letters.

outputFormat

Output a single integer to standard output (stdout) that represents the number of distinct substrings of s modulo \(10^9+7\).

## sample
4
abcd
10

</p>