#abc324e. E - Joint Two Strings
E - Joint Two Strings
Score : points
问题描述
你将得到 个由小写英文字母组成的字符串 ,以及一个由小写英文字母组成的字符串 。
存在 对整数 ,满足 。请输出在这些对中满足以下条件的对的数量。
- 将 和 按照顺序拼接后,其中包含 作为(不一定连续的)子序列。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings consisting of lowercase English letters, and a string consisting of lowercase English letters.
There are pairs of integers between and , inclusive. Print the number of pairs among them that satisfy the following condition.
- The concatenation of and in this order contains as a (not necessarily contiguous) subsequence.
Constraints
- is an integer.
- and are strings of length to , inclusive, consisting of lowercase English letters.
- The total length of is at most .
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 bac
abba
bcb
aaca
Sample Output 1
3
The pairs that satisfy the condition in the problem statement are , as seen below.
- For , the concatenation
abbabcb
of and in this order containsbac
as a subsequence. - For , the concatenation
abbaaaca
of and in this order containsbac
as a subsequence. - For , the concatenation
bcbaaca
of and in this order containsbac
as a subsequence.
Sample Input 2
5 xx
x
x
x
x
x
Sample Output 2
25
Sample Input 3
1 y
x
Sample Output 3
0
Sample Input 4
10 ms
mkgn
m
hlms
vmsle
mxsm
nnzdhi
umsavxlb
ffnsybomr
yvmm
naouel
Sample Output 4
68
update @ 2024/3/10 01:46:28