Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.

To settle this problem, they've decided to play a game. The company name will consist of n letters. Oleg and Igor each have a set of n letters (which might contain multiple copies of the same letter, the sets can be different). Initially, the company name is denoted by n question marks. Oleg and Igor takes turns to play the game, Oleg moves first. In each turn, a player can choose one of the letters cin his set and replace any of the question marks with c. Then, a copy of the letter c is removed from his set. The game ends when all the question marks has been replaced by some letter.

For example, suppose Oleg has the set of letters {i, o, i} and Igor has the set of letters {i, m, o}. One possible game is as follows :

Initially, the company name is ???.

Oleg replaces the second question mark with 'i'. The company name becomes ?i?. The set of letters Oleg have now is {i, o}.

Igor replaces the third question mark with 'o'. The company name becomes ?io. The set of letters Igor have now is {i, m}.

Finally, Oleg replaces the first question mark with 'o'. The company name becomes oio. The set of letters Oleg have now is {i}.

In the end, the company name is oio.

Oleg wants the company name to be as lexicographically small as possible while Igor wants the company name to be as lexicographically large as possible. What will be the company name if Oleg and Igor always play optimally?

A string s = s1s2...sm is called lexicographically smaller than a string t = t1t2...tm(where s ≠ t) if si < ti where i is the smallest index such that si ≠ ti. (so sj = tjfor all j < i)

Input

The first line of input contains a string s of length n (1 ≤ n ≤ 3·105). All characters of the string are lowercase English letters. This string denotes the set of letters Oleg has initially.

The second line of input contains a string t of length n. All characters of the string are lowercase English letters. This string denotes the set of letters Igor has initially.

Output

The output should contain a string of n lowercase English letters, denoting the company name if Oleg and Igor plays optimally.

Examples

Input
tinkoff
zscoder
Output
fzfsirk
Input
xxxxxx
xxxxxx
Output
xxxxxx
Input
ioi
imo
Output
ioi

题意:甲乙两人各持有一个长度均为n的字符串,轮着向一个新的长也为n的字符串里放字符,甲先行。
甲每一步都试图让字符串按字典序最小化,乙每一步都试图让字符串按字典序最大化。问最后这新字符串是什么。
 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("DATA.txt","r",stdin)
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 0x7fffffff;
const int mod = 1e9 + ;
const int maxn = 4e5 + ;
int n, k, a[maxn], ans[maxn];
char s1[maxn], s2[maxn], s3[maxn];
int cmp(char x, char y) {
return x > y;
}
int main() {
scanf("%s%s", s1, s2);
int n = strlen(s1), k = ;
sort(s1, s1 + n);
sort(s2, s2 + n, cmp);
int i = , j = , ed1 = (n - ) / , ed2 = (n - ) / , L = , R = n - ;
if (n & ) ed2--;
while(k < n) {
if (k % == ) {
if (s1[i] >= s2[j]) s3[R--] = s1[ed1--];
else s3[L++] = s1[i++];
} else {
if (s2[j] <= s1[i]) s3[R--] = s2[ed2--];
else s3[L++] = s2[j++];
}
k++;
}
s3[n] = '\0';
printf("%s\n", s3);
return ;
}

最新文章

  1. 如何在VMware虚拟机间建立共享磁盘?
  2. JSON结构
  3. hdu1561-The more, The Better(树形dp)
  4. Linux压力测试软件Stress安装及使用指南
  5. FC经典游戏还原之:松鼠大作战2
  6. 【伯乐在线】Java线程面试题 Top 50
  7. 知识小罐头09(tomcat8启动源码分析 下)
  8. HBase篇--HBase操作Api和Java操作Hbase相关Api
  9. MyBatis使用注意事项
  10. opencv自带fast_math.hpp
  11. 谷歌技术&quot;三宝&quot;之MapReduce
  12. Aircrack-ng破解WPA/WPA2加密WiFi教程(Kali)
  13. 关于js特效轮播图练习
  14. centos6.5修改主机名
  15. linux命令学习之:ps
  16. js 语法高亮插件之 Prism.js
  17. Unity Shader-渲染队列,ZTest,ZWrite,Early-Z
  18. P1903 [国家集训队]数颜色 带修改莫队板子
  19. go的基结构体如何使用派生结构体的方法
  20. 使用无线网卡搭建虚拟wifi

热门文章

  1. leetcode-岛屿的个数
  2. [Clr via C#读书笔记]Cp7常量和字段
  3. 【Python 开发】第二篇 :Python安装
  4. LeetCode - 167. Two Sum II - Input array is sorted - O(n) - ( C++ ) - 解题报告
  5. UVa 340 - Master-Mind Hints 解题报告 - C语言
  6. POJ 2069 Super Star(计算几何の最小球包含+模拟退火)
  7. JavaScript闭包总结
  8. Python字符串中的r前缀
  9. 如果jsp表单元素的值为空,如何避免null出现在页面上?
  10. (三)java字符串