#P9576. 「TAOI-2」Ciallo~(∠・ω< )⌒★

    ID: 10529 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>二分树状数组洛谷原创O2优化哈希 hashing洛谷月赛

「TAOI-2」Ciallo~(∠・ω< )⌒★

Background

Yuzu fans, that is enough.

~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)

Problem Description

Little δ\delta likes to make up words. He learned a way to make up words.

First, he has a "template string", denoted as ss. Then he chooses a pair 1lrs1 \le l \le r \le |s|, deletes the ll-th to rr-th characters of ss, and concatenates the remaining parts. He denotes the new string obtained as ss'.

Next, he chooses a new pair 1lrs1 \le l' \le r' \le |s'|, and lets ss'' be the string formed by the ll'-th to rr'-th characters of ss'. The word he makes is ss''.

For example, if the "template string" is s=cciaohalloos=\texttt{cciaohalloo}, then one way is to choose l=5l=5, r=7r=7, obtaining s=ccialloos'=\texttt{ccialloo}, then choose l=2l'=2, r=7r'=7, obtaining s=ciallos''=\texttt{ciallo}.

Now little δ\delta has a "target string" tt. He wants to know how many different plans can use the "template string" ss to produce the word tt. Two plans are defined to be the same if and only if the chosen l,r,l,rl,r,l',r' are all the same.

Input Format

There are two lines, which are the strings ss and tt, respectively.

Output Format

There is one line, representing the number of plans to produce the "target string" tt.

aabbaaba
aba
23
ciaohallo
ciallo
2
babacbbaababbacbababbabbbaaabaabababbabbabababba
ababab
1535
sssssssssssssssssssssssssssssssssssss
sss
15470
abcbbbcbcbcbacbacbaaabcbcbcbaabacbca
cb
3995

Hint

Constraints

This problem uses bundled testdata.

  • Subtask 0 (6 points): s400|s| \le 400, t200|t| \le 200.
  • Subtask 1 (10 points): s700|s| \le 700, t300|t| \le 300.
  • Subtask 2 (10 points): i,j,si=tj\forall i,j,s_i=t_j.
  • Subtask 3 (10 points): t=1|t|=1.
  • Subtask 4 (20 points): s104|s| \le 10^4, t3×103|t| \le 3 \times 10^3.
  • Subtask 5 (14 points): t=2|t|=2.
  • Subtask 6 (30 points): No special constraints.

For all testdata, 1s4×1051 \le |s| \le 4 \times 10^5, 1t2×1051 \le |t| \le 2 \times 10^5. s,ts,t contain only lowercase English letters.

Translated by ChatGPT 5