#P5479. [BJOI2015] 隐身术

[BJOI2015] 隐身术

Description

Given two strings AA and BB. How many non-empty substrings of BB have an edit distance to AA that is at most KK?

A “substring” means a consecutive segment of BB. Substrings with the same content but different positions are counted multiple times. The “edit distance” between two strings is the minimum number of operations needed to change one string into the other. Each operation can insert, delete, or replace one character.

Input Format

The first line contains a non-negative integer KK. The next two lines each contain a string of uppercase letters, representing AA and BB respectively.

Output Format

Output one line containing an integer, which is the required answer.

1
AAA
AABBAAB
5

Hint

For 100%100\% of the data, K5K\leq5, both strings are non-empty, and the sum of their lengths is less than 10510^5.

Translated by ChatGPT 5