P3181 [HAOI2016] Find Identical Characters
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 $s_1, s_2$, of lengths $n_1, n_2$, respectively.
Output Format
Output a single integer representing the answer.
Explanation/Hint
$1 \le n_1, n_2 \le 2 \times 10^5$, and the strings contain only lowercase letters.
Translated by ChatGPT 5