La Vie En Rose
Time limit2.5sMemory limit64 MB
Count which length-m windows of s can be produced from pattern p by swapping disjoint adjacent pairs that are non-overlapping and strictly separated.
- Level
Hard8 of 10
- Topics
- String matching, Dynamic programming, String, Bit manipulation
- Solved
- No attempts yet
Problem
Professor Zhang would like to solve the multiple pattern matching problem, but he has only one pattern string . So he wants to generate as many pattern strings as possible from using the following method:
- Select some indices such that and for all .
- Swap and for all .
Now, given a string , Professor Zhang wants to find all occurrences of all the generated patterns in .
Input
The first line contains two integers and (, ): the lengths of and , respectively.
The second line contains the string , and the third line contains the string . Both strings consist only of lowercase English letters.
Output
Output a binary string of length . The -th character must be '1' if and only if the substring is one of the generated patterns. Otherwise, the character must be '0'.