545B codeforces - Equidstant Strings


545B codeforces - Equidstant Strings






Solution in C++


#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
#define pii pair<int,int>

int n,lol,trn=1;
string inp1,inp2,ne;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>inp1>>inp2;
    n=inp1.size();
    for(int i=0;i<n;i++)
    {
        if(inp1[i]==inp2[i])lol++,ne+=inp2[i];
        else if(trn%2)ne+=inp1[i],trn++;
        else ne+=inp2[i],trn++;
    }
    if( (n-lol)%2 )return cout<<"impossible",0;
    cout<<ne;
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق