D、Encrypted String Matching
题号:NC17243
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Eddy is eavesdropping the messages passed between Alice and Bob. He has collected several cipher texts. From those cipher texts, Eddy has discovered that Alice and Bob is using Caesar cipher to encrypt their messages and successfully recover the Caesar table they used. Now, Eddy wants to extract some information from their communication. However, Eddy found that the Caesar encryption system they used is a little bit broken. That is, if some character should be encrypted into c, the ascii code of actual output might be differed by one. For example, if some character should be encrypted into , it may output or or . But, if one should be encrypted into , it may output or .

Eddy has found that the plain text of target key word is S and eavesdropped the message
decrypted into T. He is now wondering how many substring of T may be actually the same as S considering that the Caesar system is broken.

A substring T' may be actually the same as S if we can encrypt T' into E(T') in the broken way. Then, decrypt E(T') into D(E(T')) in normal way, where D(E(T'))=S

输入描述:

The input contains 3 lines.
The first line is the target key word S.
The second line is the decrypted plain text T.
The third line is the Caesar table P used where will be encrypted into the first character of P, will be encrypted into the second one, and so on.

1 ≤ |S| ≤ |T| ≤ 250000
The strings S and T are consisting of lowercase English letters.
|P|=26, which is a permutation of lowercase English letters.

输出描述:

Please output one or two lines.
The first line is the number of possible matching positions.
If there is any matching position,
output one more line with matching positions in ascending order and separated by a space.
示例1

输入

复制
any
amyisaboy
abcdefghijklmnopqrstuvwxyz

输出

复制
2
1 7
示例2

输入

复制
uagn
elbkanlrgthwzgrnohlned
cmlkixrnvwusqhajbtpofzgdye

输出

复制
0