CF1276F.Asterisk Substrings

NOI/NOI+/CTSC

通过率:0%

时间限制:5.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider a string ss of nn lowercase English letters. Let tit_i be the string obtained by replacing the ii-th character of ss with an asterisk character *. For example, when s=abcs = \mathtt{abc}, we have t1=∗bct_1 = \tt{*bc}, t2=a∗ct_2 = \tt{a*c}, and t3=ab∗t_3 = \tt{ab*}.

Given a string ss, count the number of distinct strings of lowercase English letters and asterisks that occur as a substring of at least one string in the set s,t1,…,tn{s, t_1, \ldots, t_n }. The empty string should be counted.

Note that *'s are just characters and do not play any special role as in, for example, regex matching.

考虑一个由 nn 个小写英文字母组成的字符串 ss。令 tit_i 表示将 ss 的第 ii 个字符替换为星号字符 * 后所得的字符串。例如,当 s=abcs = \mathtt{abc} 时,有 t1=∗bct_1 = \tt{*bc}、t2=a∗ct_2 = \tt{a*c} 和 t3=ab∗t_3 = \tt{ab*}。

给定字符串 ss,统计在集合 {s,t1,…,tn}\{s, t_1, \ldots, t_n\} 中至少一个字符串中作为子串出现的不同字符串(由小写英文字母和星号组成)的个数。空字符串应被计入。

注意:* 仅被视为普通字符,不具有任何特殊含义(例如,在正则表达式匹配中那样的通配功能)。

输入格式

The only line contains a string ss of nn lowercase English letters (1≤n≤1051 \leq n \leq 10^5).

唯一一行包含一个由 nn 个小写英文字母组成的字符串 ss(1≤n≤1051 \leq n \leq 10^5)。

输出格式

Print a single integer — the number of distinct strings of s,t1,…,tns, t_1, \ldots, t_n.

输出一个整数——字符串 s,t1,…,tns, t_1, \ldots, t_n 中互不相同的字符串的个数。

输入输出样例

  • 输入#1

    abc

    输出#1

    15

说明/提示

For the sample case, the distinct substrings are (empty string), a, b, c, *, ab, a*, bc, b*, *b, *c, abc, ab*, a*c, *bc.

对于样例,不同的子串有(空字符串)、a、b、c、*、ab、a*、bc、b*、*b、*c、abc、ab*、a*c、*bc。

输入解题思路,AI测评打分。不知道怎么写?

首页