#P7420. 「PMOI-2」拆分

「PMOI-2」拆分

Background

If you do not read the hints in the sample explanation, you will most likely be unable to solve it.

Problem Description

lhm has a string aa and its substring bb. Now you need to split the string aa.

Let c(s,b)c(s,b) denote the maximum number of substrings that can be selected from string ss such that they are pairwise non-overlapping and equal to bb.

If we split aa into kk groups, and denote the ii-th group as pip_i, you need to ensure:

  • k2k \geq 2,
  • c(pi+1,b)>c(pi,b) (i[1,k1])c(p_{i+1},b) > c(p_i,b)\ (i \in [1,k-1]),
  • c(p1,b)1c(p_1,b) \geq 1.

Two splitting plans are different if and only if the number of groups after splitting is different, or i\exist i such that the corresponding c(pi,b)c(p_i,b) values are different.

Find the total number of different splitting plans, and output the answer modulo 899678209899678209.

Input Format

The input consists of two lines.

The first line contains a string aa, with the meaning as described in the problem.

The second line contains a string bb, with the meaning as described in the problem.

Output Format

The output consists of one line.

Print one integer, representing the number of splitting plans modulo 899678209899678209.

noinoinonoinoiionoinoinoionoi
noi
10

Hint

[Sample Explanation]

The splitting methods are:

noi noinonoi noiionoinoinoionoi, with counts 1,2,51,2,5.

noi noinonoin oiionoinoinoionoi, with counts 1,2,41,2,4.

noino inonoinoiion oinoinoionoi, with counts 1,2,31,2,3.

noi noinonoinoi ionoinoinoionoi, with counts 1,3,41,3,4.

noi noinonoinoiionoinoinoionoi, with counts 1,71,7.

noinoi nonoinoiionoinoinoionoi, with counts 2,62,6.

noinoinonoi noiionoinoinoionoi, with counts 3,53,5.

noin oinonoinoiionoinoinoionoi, with counts 1,61,6.

noinoinono inoiionoinoinoionoi, with counts 2,52,5.

noinoinonoin oiionoinoinoionoi, with counts 3,43,4.

Hint: The sample explanation is enough to show that splitting inside a substring is allowed.

[Constraints]

Please read this section carefully.

This problem uses bundled testdata.

Let n=c(a,b)n = c(a,b), a=l1|a| = l_1, and b=l2|b| = l_2.

Subtask Special Property Memory Limit Score
1 l130l_1 \leq 30 256MiB 9
2 n300n \le 300 11
3 n2000n \le 2000 17
4 n25000n \le 25000 37
5 None 64MiB 26

For 100%100\% of the testdata, 0n2×1050 \le n \le 2\times10^5, 2l2l11062 \le l_2 \le l_1 \le 10^6, b1bl2b_1 \neq b_{l_2}, and both aa and bb contain only lowercase letters.

Translated by ChatGPT 5