CF113B.Petr#

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the s__begin and ending with the s__end (it is possible s__begin = s__end), the given string t has. Substrings are different if and only if their contents aren't equal, their positions of occurence don't matter. Petya wasn't quite good at math, that's why he couldn't count this number. Help him!

很久以前,当佩佳还是个小学生时,他对 Petr# 语言的语法规则非常着迷。在一次课上,佩佳对如下问题产生了兴趣:给定字符串 tt,它包含多少个不同的连续子串,这些子串以 sbegins_{\text{begin}} 开头、以 sends_{\text{end}} 结尾(允许 sbegin=sends_{\text{begin}} = s_{\text{end}})?当且仅当两个子串的内容不相等时,它们才被视为不同;子串出现的位置不影响其是否被视作相同。佩佳的数学不太好,因此无法算出这个数目。请帮帮他!

输入格式

The input file consists of three lines. The first line contains string t. The second and the third lines contain the s__begin and s__end identificators, correspondingly. All three lines are non-empty strings consisting of lowercase Latin letters. The length of each string doesn't exceed 2000 characters.

输入文件包含三行。第一行包含字符串 tt。第二行和第三行分别包含标识符 sbegins_{\text{begin}} 和 sends_{\text{end}}。这三行均为非空字符串,且仅由小写拉丁字母组成。每个字符串的长度均不超过 2000 个字符。

输出格式

Output the only number — the amount of different substrings of t that start with s__begin and end with s__end.

输出唯一的数字——字符串 tt 中以 sbegins_{\text{begin}} 开头且以 sends_{\text{end}} 结尾的不同子串的数量。

输入输出样例

  • 输入#1

    round
    ro
    ou

    输出#1

    1
  • 输入#2

    codeforces
    code
    forca

    输出#2

    0
  • 输入#3

    abababab
    a
    b

    输出#3

    4
  • 输入#4

    aba
    ab
    ba

    输出#4

    1

说明/提示

In the third sample there are four appropriate different substrings. They are: ab, abab, ababab, abababab.

In the fourth sample identificators intersect.

在第三个样例中,有四个合适的不同的子串。它们是:ab、abab、ababab、abababab。

在第四个样例中,标识符相互重叠。

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

首页