A+B
Time limit2sMemory limit64 MB
Given forbidden strings V, find the lexicographic index sum of A and B among all strings orthogonal to V, then output the string at that index modulo the count.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics, String
- Solved
- No attempts yet
Problem
Two strings and of the same length are called orthogonal if for every with . A string of length is orthogonal to a set of strings (each also of length ) if is orthogonal to for every with .
Fix the alphabet of lowercase English letters. Given a set , take all strings of length that are orthogonal to and sort them in ascending lexicographic order. This yields a sequence , where is the number of such strings.
The orthogonal sum of and is the string where .
Given the set and two strings and (both orthogonal to ), compute the orthogonal sum of and with respect to .
Input
The first line contains two integers and : the length of each string () and the number of strings in , with . Each of the next lines contains one string . The following two lines contain the strings and , each of length .
All strings , , and consist of lowercase English letters. It is guaranteed that and are orthogonal to .
Output
Print the orthogonal sum of and with respect to .