Codeforces Round 635 (Div. 2)
E
Kaavi and Magic Spell
Codeforces
未评级
原题
← DF →
翻译中…

Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future.

翻译中…

image

翻译中…

Kaavi has a string $T$ of length $m$ and all the strings with the prefix $T$ are magic spells. Kaavi also has a string $S$ of length $n$ and an empty string $A$.

翻译中…

During the divination, Kaavi needs to perform a sequence of operations. There are two different operations:

翻译中…
  • Delete the first character of $S$ and add it at the front of $A$.
  • Delete the first character of $S$ and add it at the back of $A$.
翻译中…

Kaavi can perform no more than $n$ operations. To finish the divination, she wants to know the number of different operation sequences to make $A$ a magic spell (i.e. with the prefix $T$). As her assistant, can you help her? The answer might be huge, so Kaavi only needs to know the answer modulo $998\,244\,353$.

翻译中…

Two operation sequences are considered different if they are different in length or there exists an $i$ that their $i$-th operation is different.

翻译中…

A substring is a contiguous sequence of characters within a string. A prefix of a string $S$ is a substring of $S$ that occurs at the beginning of $S$.

翻译中…

Input

翻译中…

The first line contains a string $S$ of length $n$ ($1 \leq n \leq 3000$).

翻译中…

The second line contains a string $T$ of length $m$ ($1 \leq m \leq n$).

翻译中…

Both strings contain only lowercase Latin letters.

翻译中…

Output

翻译中…

The output contains only one integer  — the answer modulo $998\,244\,353$.

翻译中…

Note

翻译中…

The first test:

翻译中…

image

翻译中…

The red ones are the magic spells. In the first operation, Kaavi can either add the first character "a" at the front or the back of $A$, although the results are the same, they are considered as different operations. So the answer is $6\times2=12$.

翻译中…

样例

Input #1
abab
ba
Output #1
12
InputCopy OutputCopy
Input #2
defineintlonglong
signedmain
Output #2
0
InputCopy OutputCopy
Input #3
rotator
rotator
Output #3
4
InputCopy OutputCopy
Input #4
cacdcdbbbb
bdcaccdbbb
Output #4
24
InputCopy OutputCopy
题目信息
题号
1337E
时间限制
2 s
内存限制
512 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。