#P4712. Equidistant String

Equidistant String

Equidistant String

题面翻译

题目描述

Susie 喜欢字符串。她的字符串只包含数字 0011。今天,她使用了汉明距离法计算了它们之间的距离。

汉明距离的定义表示两个相同长度字符串对应位置的不同字符的数量。

有2个长度为 nn 的字符串 sstt 她还想要一个长度为 nn 的字符串 pp 使得 ppss 的距离等于 pptt 的距离

请你帮她找到这样的字符串 pp。可能有很多种答案,找到一种即可。

输入格式

第一行是字符串 ss

第二行是字符串 tt

输出格式

输出一行字符串 pp,如果不存在满足要求的字符串 pp,输出 impossible

样例说明

第一组样例:汉明距离为3

答案也可以为 10011001

第二组样例:无法找到满足要求的字符串

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 s s and t t of the same length consisting of digits zero and one as the number of positions i i , such that si s_{i} isn't equal to ti t_{i} .

As besides everything else Susie loves symmetry, she wants to find for two strings s s and t t of length n n such string p p of length n n , that the distance from p p to s s was equal to the distance from p p to t t .

It's time for Susie to go to bed, help her find such string p p or state that it is impossible.

输入格式

The first line contains string s s of length n n .

The second line contains string t t of length n n .

The length of string n n is within range from 1 1 to 105 10^{5} . It is guaranteed that both strings contain only digits zero and one.

输出格式

Print a string of length n n , 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.