H Levenshtein Distance
题号:NC224735
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

The Levenshtein Distance between two strings is the smallest number of simple one-letter operations
needed to change one string to the other. The operations are:
1. Adding a letter anywhere in the string.
2. Removing a letter from anywhere in the string.
3. Changing any letter in the string to any other letter.

Given a specific alphabet and a particular query string, find all other unique strings from that alphabet
that are at a Levenshtein Distance of 1 from the given string, and list them in alphabetical order, with no duplicates.

Note that the query string must not be in the list. Its Levenshtein Distance from itself is 0, not 1.

输入描述:

Input consists of exactly two lines. The first line of input contains a sequence of unique lower-case
letters, in alphabetical order, with no spaces between them. This is the alphabet to use.

The second line contains a string 𝒔 (2 ≤ |𝒔| ≤ 100), which consists only of lower-case letters from the
given alphabet. This is the query string.

输出描述:

Output a list, in alphabetical order, of all strings which are a  Levenshtein Distance of 1 from the query string 𝒔.
 Output one word per line, with no duplicates. 

示例1

输入

复制
eg 
egg

输出

复制
eeg 
eegg 
eg 
ege 
egeg 
egge 
eggg 
gegg 
gg 
ggg