B. Equidistant String
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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

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

Input

The first line contains string s of length n.

The second line contains string t of length n.

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

Output

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

Examples
input
0001
1011
output
0011
input
000
111
output
impossible
Note

In the first sample different answers are possible, namely — 0010, 0011, 0110, 0111, 1000, 1001, 1100, 1101.

题意:给你两个长度相同的01串s,t   找到一个新的01串p

使得p与s对应位置 字符不同的数量 等于 p与t对应位置 字符不同 的数量

不存在则输出impossible

题解:遍历一遍统计s,t对应位置字符不同的数量jishu 并标记位置

如果jishu是奇数 则输出impossible 否则 取s串 对于标记的位置  取反jishu/2个位置的值

输出

 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
#include<queue>
#include<cmath>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
char a[];
char b[];
int mp[];
int main()
{
memset(mp,,sizeof(mp));
scanf("%s",a);
scanf("%s",b);
int len=strlen(a);
int jishu=;
for(int i=;i<len;i++)
{
if(a[i]!=b[i])
{ jishu++;
mp[i]=;
}
}
if(jishu%)
{
printf("impossible\n");
return ;
}
jishu/=;
for(int i=;i<len;i++)
{
if(jishu)
{
if(mp[i])
{
if(a[i]=='')
printf("");
else
printf("");
jishu--;
}
else
printf("%c",a[i]);
}
else
printf("%c",a[i]);
}
return ;
}

最新文章

  1. npm ERR publish 403,nodejs发布包流程
  2. android 文字写在图片上
  3. javascript设计模式-组合模式
  4. JAVA学习第五十七课 — IO流(十一)
  5. Django 后台搭建
  6. 转载:redis备份策略
  7. hadoop处理Excel通话记录
  8. 10.24 noip模拟试题
  9. C#学习心得,记录学习
  10. OpenCV基础篇之查找表
  11. banner | what is the &quot;banner&quot; ?
  12. js中Attribute和property的区别与联系
  13. weex开发错误汇总
  14. 【vue】vue使用Element组件时v-for循环里的表单项验证方法
  15. 微信小程序app.json配置
  16. redis安装及注意事项
  17. linux系统编程之信号(五):信号集操作函数,信号阻塞与未决
  18. python-文件基本操作(一) (转载)
  19. [微软官网]SQLSERVER的版本信息
  20. Spring和springmvc父子容器注解扫描问题详解

热门文章

  1. LCD驱动 15 -2
  2. 解决VS2010控制台程序运行结束不显示请按任意键继续
  3. vue js 用nodejs的依赖包 --2016-08-23
  4. OpenCV之响应鼠标(一):利用鼠标获取坐标
  5. 新发布GoldenGate 12c版本中的主要特性
  6. JAVA SERVLET专题(上)
  7. Spark的编译
  8. EasyUI 验证框使用方法
  9. (转)在网页中JS函数自动执行常用三种方法
  10. 12-26 tableView的学习心得