luogu#P3181. [HAOI2016] 找相同字符

    ID: 2250 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串2016河南各省省选后缀数组 SA

[HAOI2016] 找相同字符

Problem Description

Given two strings, count the number of ways to take one substring from each string such that the two substrings are equal. Two ways are different if and only if at least one of the substrings has a different position.

Input Format

Two lines: two strings s1,s2s_1, s_2, of lengths n1,n2n_1, n_2, respectively.

Output Format

Output a single integer representing the answer.

aabb
bbaa
10

Hint

1n1,n22×1051 \le n_1, n_2 \le 2 \times 10^5, and the strings contain only lowercase letters.

Translated by ChatGPT 5