Pinely Round 3 (Div. 1 + Div. 2) |
---|
Finished |
You are given two strings $$$s$$$, $$$t$$$ of length $$$n$$$, $$$m$$$, respectively. Both strings consist of lowercase letters of the English alphabet.
Count the triples $$$(x, y, z)$$$ of strings such that the following conditions are true:
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n < m \leq 10^7$$$) — the length of the strings $$$s$$$ and $$$t$$$, respectively.
The second line contains the string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the English alphabet.
The third line contains the string $$$t$$$ of length $$$m$$$, consisting of lowercase letters of the English alphabet.
Output a single integer: the number of valid triples $$$(x, y, z)$$$.
4 8abcdabcbcbcd
1
3 5aaaaaaaa
5
12 16abbababacaababbababababacaab
8
In the first test case, the only valid triple is $$$(x, y, z) = (\texttt{"a"}, \texttt{"bc"}, \texttt{"d"})$$$. In fact,
In the second test case, there are $$$5$$$ valid triples:
In the third test case, there are $$$8$$$ valid triples:
Name |
---|