QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#8607. Find Identical Substrings

Statistiques

Given two strings, find the number of ways to choose one substring from each string such that the two substrings are identical. Two ways are considered different if and only if the substrings differ in at least one position (i.e., they have different starting or ending positions in their respective strings).

Input

Two lines, each containing a string $s1$ and $s2$, with lengths $n1$ and $n2$ respectively.

Output

Output an integer representing the answer.

Constraints

  • For 20% of the data, $1 \le n1, n2 \le 500$.
  • For 40% of the data, $1 \le n1, n2 \le 5000$.
  • For 100% of the data, $1 \le n1, n2 \le 200000$, and the strings consist only of lowercase letters.

Examples

Input 1

aabb
bbaa

Output 1

10

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.