B - Substring Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200200

問題文

英小文字からなる文字列 SS が与えられます。SS の空でない部分文字列は何種類ありますか?

ただし、部分文字列とは連続する部分列のことを指します。例えば、xxxyxxxy の部分文字列ですが、xxyxx の部分文字列ではありません。

制約

  • SS は英小文字からなる長さ 11 以上 100100 以下の文字列

入力

入力は以下の形式で標準入力から与えられる。

SS

出力

答えを出力せよ。


入力例 1Copy

Copy
yay

出力例 1Copy

Copy
5

SS の空でない部分文字列は以下の 55 種類です。

  • a
  • y
  • ay
  • ya
  • yay

入力例 2Copy

Copy
aababc

出力例 2Copy

Copy
17

入力例 3Copy

Copy
abracadabra

出力例 3Copy

Copy
54

Score: 200200 points

Problem Statement

You are given a string SS consisting of lowercase English letters. How many different non-empty substrings does SS have?

A substring is a contiguous subsequence. For example, xxx is a substring of yxxxy but not of xxyxx.

Constraints

  • SS is a string of length between 11 and 100100, inclusive, consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

SS

Output

Print the answer.


Sample Input 1Copy

Copy
yay

Sample Output 1Copy

Copy
5

SS has the following five different non-empty substrings:

  • a
  • y
  • ay
  • ya
  • yay

Sample Input 2Copy

Copy
aababc

Sample Output 2Copy

Copy
17

Sample Input 3Copy

Copy
abracadabra

Sample Output 3Copy

Copy
54


2025-04-26 (Sat)
03:07:41 +00:00