#P16104. [ICPC 2019 NAIPC] Subsequences in Substrings

[ICPC 2019 NAIPC] Subsequences in Substrings

题目描述

You are given two strings ss, and tt. Count the number of substrings of ss that contain tt as a subsequence at least once.

Note that a substring and a subsequence both consist of characters from the original string, in order. In a substring, the characters must be contiguous in the original string, but in a subsequence, they are not required to be contiguous. In the string abcde, ace is a subsequence but not a substring.

If ss is aa and tt is a, then the answer is 3: [a]a, [aa], and a[a].

输入格式

Each test case will consist of exactly two lines.

The first line will contain string ss (1s1051 \leq |s| \leq 10^5, s[az]s \in [a-z]^*), with no other characters.

The second line will contain string tt (1t1001 \leq |t| \leq 100, ts|t| \leq |s|, t[az]t \in [a-z]^*), with no other characters.

输出格式

Output a single integer, which is the number of substrings of ss that contain tt as a subsequence at least once.

abcdefghijklmnopqrstuvwxyz
a
26
abcdefghijklmnopqrstuvwxyz
m
182
penpineappleapplepen
ppap
68