
#include "bits/stdc++.h"
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define OPEN freopen (".in", "r", stdin); freopen (".out", "w", stdout);
#define pc __builtin_popcount
#define db double
#define pii pair<int, int>
#define fi first
#define se second
#define F(i,x,y) for (int i = (x); i <= (y); ++i)
#define D(i,x,y) for (int i = (x); i >= (y); --i)
using namespace std;
const ll inf = 1ll * 1e18;
//const ll mod = 998244353ll;
int n, m, x;
const ll mod = 1ll * 1e9 + 7ll;
inline void Rd(int& x) {
int f = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c - 48), c = getchar();
x *= f;
}
inline void Wt(int x) {
if (x < 10) {
putchar(x + 48);
return;
}
Wt(x / 10);
putchar((x % 10) + 48);
}
string a, b;
string ra, rb;
//int n;
int _pos, tag;
int lp, rp;
string c;
bool cmp(char x, char y) {
return x > y;
}
int main() {
// OPEN
// IOSc
cin >> ra >> rb;
sort (ra.begin(), ra.end());
sort (rb.begin(), rb.end(), cmp);
n = ra.size();
a = ' ' + ra, b = ' ' + rb;
cerr << a << '\n' << b << '\n';
c = " ";
lp = 0, rp = n + 1;
F(i, 1, n << 2) c += '?';
int flg = 0;
F(i, 1, n) {
if (a[i] < b[i]) {
c[++ lp] = a[i];
if (lp == rp || (lp + 1 == rp)) break ;
if (i != n && a[i + 1] > b[i + 1]) c[-- rp] = b[n / 2], tag = 1;
else c[++ lp] = b[i];
// cerr << a[i] << ' ' << b[i] << ' ' << a[i + 1] << ' ' << c << ' '<< i << '\n';
} else {
if (! _pos) _pos = i;
break ;
}
}
if (_pos) {
if (n & 1) {
for (int i = n / 2 + 1, j = n / 2 - tag; i >= _pos; -- i,-- j) {
// cerr << c << ' ' << a[i] << ' ' << b[j] << '\n';
c[-- rp] = a[i];
if (lp == rp || (lp + 1 == rp)) break ;
c[-- rp] = b[j];
}
// cerr << c <<
} else {
for (int i = n / 2, j = n / 2 - tag; i >= _pos; -- i,-- j) {
// cerr << c << ' ' << a[i] << ' ' << b[j] << '\n';
c[-- rp] = a[i];
if (lp == rp || (lp + 1 == rp)) break ;
c[-- rp] = b[j];
}
}
}
F(i, 1, n) cout << c[i];
}
如果贪心策略有问题,可以说下哪里有问题吗(