L1-086 斯德哥尔摩火车上的题 分数 15

// 4'34"
#include <bits/stdc++.h>
using namespace std;
string func(string s)
{
    string res;
    for(int i = 1; i < s.size(); ++ i)
        if((s[i] - '0') % 2 == (s[i - 1] - '0') % 2)
            res += max(s[i], s[i - 1]);
    return res;
}
int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    string r1 = func(s1), r2 = func(s2);
    if(r1 == r2) cout << r1 << endl;
    else cout << r1 << endl << r2 << endl;
    return 0;
}
posted @ 2024-08-20 16:02  Frodnx  阅读(23)  评论(0)    收藏  举报