[Codeforces 113B] Petr

Description

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 sbegin and ending with the send (it is possible sbegin = send), 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!

Input

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

Output

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

Solution

n辣么小,暴力随意艹

枚举起始点,枚举终止点,哈希判B串,map判本质不同

但是这样带了个\log,我就很光荣的挂掉了

换了一发unordered就过了QQ图片20160623113040

 

发表评论