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.

Sample test(s)

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.

判断字符不同的个数

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-9
#define LL long long
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define CRR fclose(stdin)
#define CWW fclose(stdout)
#define RR freopen("input.txt","r",stdin)
#pragma comment(linker,"/STACK:102400000")
#define WW freopen("output.txt","w",stdout) const int Max = 1e5; char s[Max*10];
char t[Max*10];
char p[Max*10];
int num;
int main()
{
int len;
scanf("%s",s);
scanf("%s",t);
len=strlen(s);
num=0;
for(int i=0;i<len;i++)
{
if(s[i]==t[i])
{
p[i]=s[i];
}
if(s[i]!=t[i])
{
num++;
if(num&1)
{
p[i]=s[i];
}
else
{
p[i]=t[i];
}
}
}
if(num==0)
{
printf("%s",s);
}
else if(num&1)
{
printf("impossible\n");
}
else
{
p[len]='\0';
printf("%s\n",p);
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

周赛-Equidistant String 分类: 比赛 2015-08-08 15:44 6人阅读 评论(0) 收藏的更多相关文章

  1. Find The Multiple 分类: 搜索 POJ 2015-08-09 15:19 3人阅读 评论(0) 收藏

    Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21851 Accepted: 8984 Sp ...

  2. Ultra-QuickSort 分类: POJ 排序 2015-08-03 15:39 2人阅读 评论(0) 收藏

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 48111   Accepted: 17549 ...

  3. Drainage Ditches 分类: POJ 图论 2015-07-29 15:01 7人阅读 评论(0) 收藏

    Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62016 Accepted: 23808 De ...

  4. Injector Job深入分析 分类: H3_NUTCH 2015-03-10 15:44 334人阅读 评论(0) 收藏

    Injector Job的主要功能是根据crawlId在hbase中创建一个表,将将文本中的seed注入表中. (一)命令执行 1.运行命令 [jediael@master local]$ bin/n ...

  5. Windows7下QT5开发环境搭建 分类: QT开发 2015-03-09 23:44 65人阅读 评论(0) 收藏

    Windows7下QT开法环境常见搭配方法有两种. 第一种是:QT Creator+QT SDK: 第二种是:VS+qt-vs-addin+QT SDK: 以上两种均可,所需文件见QT社区,QT下载地 ...

  6. cf 61E. Enemy is weak 树状数组求逆序数(WA) 分类: Brush Mode 2014-10-19 15:16 104人阅读 评论(0) 收藏

    #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> ...

  7. max_flow(Dinic) 分类: ACM TYPE 2014-09-02 15:42 94人阅读 评论(0) 收藏

    #include <cstdio> #include <iostream> #include <cstring> #include<queue> #in ...

  8. SQL 分组 加列 加自编号 自编号限定 分类: SQL Server 2014-11-25 15:41 283人阅读 评论(0) 收藏

    说明: (1)日期以年月形式显示:convert(varchar(7),字段名,120) , (2)加一列 (3)自编号: row_number() over(order by 字段名 desc) a ...

  9. SQL 按月统计(两种方式) 分类: SQL Server 2014-08-04 15:36 154人阅读 评论(0) 收藏

    (1)Convert 函数 select Convert ( VARCHAR(7),ComeDate,120) as Date ,Count(In_code) as 单数,Sum(SumTrueNum ...

随机推荐

  1. navicat的简单应用

    首先  创建连接 主机名 : 可以不写名称随意 主机名/IP地址:localhost或者127.0.0.1 都是本机的意思 端口:默认3306   尽量不要改怕与其余端口重复,如有重名端口系统会报错 ...

  2. C++builder 图像字符流的存储和加载

    __fastcall TForm6::TForm6(TComponent* Owner) : TForm(Owner) { #if 1 //for debug AllocConsole(); Atta ...

  3. 反射认识_06_ArrayList_HashSet区别

    包01: package ReflectionCollection; public class ReflectionConstructorPoint { private int x; public i ...

  4. mldn android

    ed2k://|file|%E9%AD%94%E4%B9%90%E7%A7%91%E6%8A%80_Android%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98%E7%BB% ...

  5. paper 8:支持向量机系列五:Numerical Optimization —— 简要介绍求解求解 SVM 的数值优化算法。

    作为支持向量机系列的基本篇的最后一篇文章,我在这里打算简单地介绍一下用于优化 dual 问题的 Sequential Minimal Optimization (SMO) 方法.确确实实只是简单介绍一 ...

  6. 11.Java反射机制 哦对了,前面的序号来自随笔关于编程之路的思索第一篇

    基本概念 在Java运行时环境中,对于任意一个类,能否知道这个类有哪些属性和方法?对于任意一个对象,能否调用它的任意一个方法? 答案是肯定的. 这种动态获取类的信息以及动态调用对象的方法的功能来自于J ...

  7. Android真机测试 INSTALL_FAILED_INSUFFICIENT_STORAGE 解决方法[转]

    方法一: 试试修改一下manifest文件 :添加 一句:   android:installLocation="preferExternal" [html]view plainc ...

  8. zw版【转发·台湾nvp系列Delphi例程】HALCON DispCross

    zw版[转发·台湾nvp系列Delphi例程]HALCON DispCross procedure TForm1.Button1Click(Sender: TObject);var r, c : Ol ...

  9. Test Android with QTP

    by Yaron Assa I have recently come across a plug-in to QTP that enables to automate tests on Android ...

  10. 关于jQuery的bind()\trigger()\triggerHandler()

    1.bind() 事件绑定. 多个事件会链式累加,而不会覆盖. 即 $("div").bind("click",funtion(){alert("te ...