#P4753. Encoding
Encoding
Encoding
题面翻译
题目描述
坡旅甲发明了一种新的字符串编码方法.
具体来说,我们可以取若干对不相交的小写字母对(每个小写字母至多出现一次),然后对于一个由小写字母组成的字符串 ,我们将 中出现在选中字母对中的字母替换为这个字母对中的另一个字母.
举个例子:我们选中了三对字母 , 和 ,那么,"parallelogram" 将会变为 "qolorreraglom"
现在,坡旅甲已经有了两个字符串 和 .他惊讶地发现, 的许多子串竟然可以通过他所发明的新编码方法得到 .于是坡旅甲想知道, 中有多少个子串可以用如上所描述的字符串编码方法编码得到
输入格式
第一行包含两个整数 ,表示 和 的串长.
接下来两行由两个小写字母字符串 和
输出格式
第一行一个整数,表示满足条件的子串个数
接下来一行按照升序输出 个整数,表示每个子串开始的位置(下标从1开始)
数据范围
题目描述
Polycarp invented a new way to encode strings. Let's assume that we have string , consisting of lowercase English letters. Let's choose several pairs of letters of the English alphabet in such a way that each letter occurs in at most one pair. Then let's replace each letter in with its pair letter if there is a pair letter for it. For example, if you chose pairs (l, r), (p, q) and (a, o), then word "parallelogram" according to the given encoding principle transforms to word "qolorreraglom".
Polycarpus already has two strings, and . He suspects that string was obtained after applying the given encoding method from some substring of string . Find all positions in ( ), such that can be obtained fro substring by applying the described encoding operation by using some set of pairs of English alphabet letters
输入格式
The first line of the input contains two integers, and ( ) — the lengths of string and string , respectively.
The second and third line of the input contain strings and , respectively. Both strings consist only of lowercase English letters.
输出格式
Print number — the number of suitable positions in string .
In the next line print integers — the numbers of the suitable positions in the increasing order.
样例 #1
样例输入 #1
11 5
abacabadaba
acaba
样例输出 #1
3
1 3 7
样例 #2
样例输入 #2
21 13
paraparallelogramgram
qolorreraglom
样例输出 #2
1
5