QOJ.ac

QOJ

时间限制: 3 s 内存限制: 1024 MB 总分: 100

#3010. 子串中的子序列

统计

给定两个字符串 $s$ 和 $t$。请计算 $s$ 中包含 $t$ 作为子序列的子串数量。

注意,子串(substring)和子序列(subsequence)均由原字符串中的字符按顺序组成。在子串中,字符在原字符串中必须是连续的;而在子序列中,字符不需要连续。例如,在字符串 $\texttt{abcde}$ 中,$\texttt{ace}$ 是一个子序列,但不是一个子串

如果 $s$ 为 $\texttt{aa}$,$t$ 为 $\texttt{a}$,则答案为 $3$:$\texttt{[a]a}$、$\texttt{[aa]}$ 和 $\texttt{a[a]}$。

输入格式

每个测试用例包含两行。 第一行包含字符串 $s$ ($1 \leq |s| \leq 10^5, s \in [a-z]^*$),不包含其他字符。

第二行包含字符串 $t$ ($1 \leq |t| \leq 100, |t| \leq |s|, t \in [a-z]^*$),不包含其他字符。

输出格式

输出一个整数,表示 $s$ 中包含 $t$ 作为子序列的子串数量。

样例

样例输入 1

abcdefghijklmnopqrstuvwxyz
a

样例输出 1

26

样例输入 2

abcdefghijklmnopqrstuvwxyz
m

样例输出 2

182

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.