#P1575H. Holiday Wall Ornaments
Holiday Wall Ornaments
Description
The Winter holiday will be here soon. Mr. Chanek wants to decorate his house's wall with ornaments. The wall can be represented as a binary string of length . His favorite nephew has another binary string of length ().
Mr. Chanek's nephew loves the non-negative integer . His nephew wants exactly occurrences of as substrings in .
However, Mr. Chanek does not know the value of . So, for each (), find the minimum number of elements in that have to be changed such that there are exactly occurrences of in .
A string occurs exactly times in if there are exactly different pairs such that we can obtain by deleting characters from the beginning and characters from the end of .
The first line contains two integers and () — size of the binary string and respectively.
The second line contains a binary string of length .
The third line contains a binary string of length .
Output integers — the -th integer denotes the minimal number of elements in that have to be changed so there are exactly occurrences of as a substring in .
Input
The first line contains two integers and () — size of the binary string and respectively.
The second line contains a binary string of length .
The third line contains a binary string of length .
Output
Output integers — the -th integer denotes the minimal number of elements in that have to be changed so there are exactly occurrences of as a substring in .
Note
For , to make the string have no occurrence of 101, you can do one character change as follows.
100101011 100100011
For , you can also change a single character.
100101011 100001011
For , no changes are needed.