#P5410. 【模板】扩展 KMP / exKMP(Z 函数)
【模板】扩展 KMP / exKMP(Z 函数)
Problem Description
Given two strings , you need to find two arrays:
- The function array of , that is, the LCP length between and each suffix of .
- The LCP length array between and each suffix of .
For an array of length , define its weight as .
Input Format
Two lines, containing two strings .
Output Format
The first line contains one integer, the weight of .
The second line contains one integer, the weight of .
aaaabaa
aaaaa
6
21
Hint
Sample explanation:
, .
Constraints:
For the first test point, .
For the second test point, .
For of the data, , and all characters are lowercase letters.
Translated by ChatGPT 5