|
||||||||||||||||
MatchesS and P are two strings consisting of lowercase letters of the English alphabet, with lengths N and M (N ≤ 10 000, M ≤ 1000, N ≥ M).
In string P, we can replace all the letters in a subsequence of choice with the
character
The number of matches of the modified P string in string S is the number of
positions on which P matches in S. P matches in S on some
position i ≤ N – M if any character
from P on position 0 ≤ j < M matches
the corresponding letter in S, more precisely, if Pj matches
Si+j (using 0-based indexing). A letter matches only itself, while the
What is the minimum cost of an operation made on P such that P has at least K matches in S? Input SpecificationThe first two lines of the input will contain strings S and P. The third line contains the natural number K (K ≤ |S| – |P| + 1). Output SpecificationPrint the minimum cost of one operation made on P such that P has at least K appearances in S. Sample Input 1
Output for Sample Input 1
Sample Input 2
Output for Sample Input 2
Sample Input 3
Output for Sample Input 3
Sample Input 4
Output for Sample Input 4
Explanation
In Sample 1, if we replace
In Sample 2, if we replace
There is no solution replacing only three characters. In Sample 3, replace all characters of P, and then there will be 5 appearances in S. In Sample 4, there is no need to change anything, P appears three times in S. |
||||||||||||||||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |