#P4712. Equidistant String
Equidistant String
Equidistant String
题面翻译
题目描述
Susie 喜欢字符串。她的字符串只包含数字 和 。今天,她使用了汉明距离法计算了它们之间的距离。
汉明距离的定义表示两个相同长度字符串对应位置的不同字符的数量。
有2个长度为 的字符串 和 她还想要一个长度为 的字符串 使得 到 的距离等于 到 的距离
请你帮她找到这样的字符串 。可能有很多种答案,找到一种即可。
输入格式
第一行是字符串
第二行是字符串
输出格式
输出一行字符串 ,如果不存在满足要求的字符串 ,输出 impossible
样例说明
第一组样例:汉明距离为3
答案也可以为
第二组样例:无法找到满足要求的字符串
translated by Yang080108
题目描述
Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:
We will define the distance between two strings and of the same length consisting of digits zero and one as the number of positions , such that isn't equal to .
As besides everything else Susie loves symmetry, she wants to find for two strings and of length such string of length , that the distance from to was equal to the distance from to .
It's time for Susie to go to bed, help her find such string or state that it is impossible.
输入格式
The first line contains string of length .
The second line contains string of length .
The length of string is within range from to . It is guaranteed that both strings contain only digits zero and one.
输出格式
Print a string of length , consisting of digits zero and one, that meets the problem statement. If no such string exist, print on a single line "impossible" (without the quotes).
If there are multiple possible answers, print any of them.
样例 #1
样例输入 #1
0001
1011
样例输出 #1
0011
样例 #2
样例输入 #2
000
111
样例输出 #2
impossible
提示
In the first sample different answers are possible, namely — 0010, 0011, 0110, 0111, 1000, 1001, 1100, 1101.