#t135. 相似字符串
相似字符串
Similar Strings
Problem Description
For two strings and , we say and are similar if can be turned into by deleting one character, inserting one character, or modifying one character.
For instance, apple can become applee by inserting a character, can become appe by deleting a character, and can become bpple by modifying a character. So apple is similar to applee, appe, and bpple. But applee cannot be turned into bpple by any single such operation, so they are not similar.
In particular, two identical strings are also similar.
Given pairs of and , determine for each pair whether they are similar.
Input Format
The first line contains a positive integer . The next lines each contain two strings and separated by a space.
Output Format
For each pair and , output similar if they are similar, otherwise output not similar.
Sample Input
5
apple applee
apple appe
apple bpple
applee bpple
apple apple
Sample Output
similar
similar
similar
not similar
similar
Sample Explanation
The sample contains test cases:
- Case 1:
appleandapplee.applecan becomeappleeby inserting aneat the end, so they are similar. - Case 2:
appleandappe.applecan becomeappeby deletingl, so they are similar. - Case 3:
appleandbpple.applecan becomebppleby changingatob, so they are similar. - Case 4:
appleeandbpple.appleecannot becomebpplewith a single delete/insert/modify operation, so they are not similar. - Case 5:
appleandapple. The two strings are identical, which also counts as similar.
So the outputs are similar, similar, similar, not similar, similar.
Constraints
For all test data, , and the lengths of and are at most . They contain only lowercase letters.