{"problem":{"name":"C. Naming Company","description":{"content":"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 compan","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF794C"},"statements":[{"statement_type":"Markdown","content":"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.\n\nTo 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 _c_ in 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.\n\nFor 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 :\n\nInitially, the company name is _???_.\n\nOleg replaces the second question mark with _'i'_. The company name becomes _?i?_. The set of letters Oleg have now is {_i_, _o_}.\n\nIgor replaces the third question mark with _'o'_. The company name becomes _?io_. The set of letters Igor have now is {_i_, _m_}.\n\nFinally, Oleg replaces the first question mark with _'o'_. The company name becomes _oio_. The set of letters Oleg have now is {_i_}.\n\nIn the end, the company name is _oio_.\n\nOleg 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?\n\nA string _s_ = _s_1_s_2..._s__m_ is called lexicographically smaller than a string _t_ = _t_1_t_2..._t__m_ (where _s_ ≠ _t_) if _s__i_ < _t__i_ where _i_ is the smallest index such that _s__i_ ≠ _t__i_. (so _s__j_ = _t__j_ for all _j_ < _i_)\n\n## Input\n\nThe 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.\n\nThe 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.\n\n## Output\n\nThe output should contain a string of _n_ lowercase English letters, denoting the company name if Oleg and Igor plays optimally.\n\n[samples]\n\n## Note\n\nOne way to play optimally in the first sample is as follows :\n\n*   Initially, the company name is _???????_.\n*   Oleg replaces the first question mark with _'f'_. The company name becomes _f??????_.\n*   Igor replaces the second question mark with _'z'_. The company name becomes _fz?????_.\n*   Oleg replaces the third question mark with _'f'_. The company name becomes _fzf????_.\n*   Igor replaces the fourth question mark with _'s'_. The company name becomes _fzfs???_.\n*   Oleg replaces the fifth question mark with _'i'_. The company name becomes _fzfsi??_.\n*   Igor replaces the sixth question mark with _'r'_. The company name becomes _fzfsir?_.\n*   Oleg replaces the seventh question mark with _'k'_. The company name becomes _fzfsirk_.\n\nFor the second sample, no matter how they play, the company name will always be _xxxxxx_.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Oleg 客户和 Igor 分析师是好朋友。然而，他们有时会为一些小事争论。最近，他们创办了一家新公司，但在公司名称上遇到了困难。\n\n为了解决这个问题，他们决定玩一个游戏。公司名称将由 #cf_span[n] 个字母组成。Oleg 和 Igor 各自拥有一组 #cf_span[n] 个字母（可能包含重复字母，两组字母可能不同）。初始时，公司名称用 #cf_span[n] 个问号表示。Oleg 和 Igor 轮流进行游戏，Oleg 先手。每轮，一名玩家可以从自己的字母集合中选择一个字母 #cf_span[c]，并用 #cf_span[c] 替换任意一个问号。然后，该字母 #cf_span[c] 的一个副本将从他的集合中移除。当所有问号都被字母替换时，游戏结束。\n\n例如，假设 Oleg 的字母集合为 #cf_span[{i, o, i}]，Igor 的字母集合为 #cf_span[{i, m, o}]。一场可能的游戏如下：\n\n初始时，公司名称为 _???_。\n\nOleg 将第二个问号替换为 _'i'_。公司名称变为 _?i?_。此时 Oleg 的字母集合为 #cf_span[{i, o}]。\n\nIgor 将第三个问号替换为 _'o'_。公司名称变为 _?io_。此时 Igor 的字母集合为 #cf_span[{i, m}]。\n\n最后，Oleg 将第一个问号替换为 _'o'_。公司名称变为 _oio_。此时 Oleg 的字母集合为 #cf_span[{i}]。\n\n最终，公司名称为 _oio_。\n\nOleg 希望公司名称的字典序尽可能小，而 Igor 希望公司名称的字典序尽可能大。如果 Oleg 和 Igor 都采取最优策略，公司名称会是什么？\n\n字符串 #cf_span[s = s1s2...sm] 被称为字典序小于字符串 #cf_span[t = t1t2...tm]（其中 #cf_span[s ≠ t]），如果存在最小的下标 #cf_span[i] 使得 #cf_span[si < ti]（即对所有 #cf_span[j < i]，有 #cf_span[sj = tj]）。\n\n输入的第一行包含一个长度为 #cf_span[n] 的字符串 #cf_span[s]（#cf_span[1 ≤ n ≤ 3·105]）。该字符串的所有字符均为小写英文字母，表示 Oleg 初始拥有的字母集合。\n\n输入的第二行包含一个长度为 #cf_span[n] 的字符串 #cf_span[t]（#cf_span[1 ≤ n ≤ 3·105]）。该字符串的所有字符均为小写英文字母，表示 Igor 初始拥有的字母集合。\n\n输出应为一个长度为 #cf_span[n] 的小写英文字母字符串，表示在 Oleg 和 Igor 均采取最优策略时的公司名称。\n\n第一个样例的一种最优玩法如下：\n\n对于第二个样例，无论他们如何玩，公司名称始终为 _xxxxxx_。\n\n## Input\n\n输入的第一行包含一个长度为 #cf_span[n] 的字符串 #cf_span[s]（#cf_span[1 ≤ n ≤ 3·105]）。该字符串的所有字符均为小写英文字母，表示 Oleg 初始拥有的字母集合。输入的第二行包含一个长度为 #cf_span[n] 的字符串 #cf_span[t]（#cf_span[1 ≤ n ≤ 3·105]）。该字符串的所有字符均为小写英文字母，表示 Igor 初始拥有的字母集合。\n\n## Output\n\n输出应为一个长度为 #cf_span[n] 的小写英文字母字符串，表示在 Oleg 和 Igor 均采取最优策略时的公司名称。\n\n[samples]\n\n## Note\n\n第一个样例的一种最优玩法如下：初始时，公司名称为 _???????_。Oleg 将第一个问号替换为 _'f'_。公司名称变为 _f??????_。Igor 将第二个问号替换为 _'z'_。公司名称变为 _fz?????_。Oleg 将第三个问号替换为 _'f'_。公司名称变为 _fzf????_。Igor 将第四个问号替换为 _'s'_。公司名称变为 _fzfs???_。Oleg 将第五个问号替换为 _'i'_。公司名称变为 _fzfsi??_。Igor 将第六个问号替换为 _'r'_。公司名称变为 _fzfsir?_。Oleg 将第七个问号替换为 _'k'_。公司名称变为 _fzfsirk_。对于第二个样例，无论他们如何玩，公司名称始终为 _xxxxxx_。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the length of the company name.  \nLet $ O \\subseteq \\Sigma $ be the multiset of letters Oleg initially has, represented as a string $ s $ of length $ n $.  \nLet $ I \\subseteq \\Sigma $ be the multiset of letters Igor initially has, represented as a string $ t $ of length $ n $.  \nLet $ \\Sigma = \\{a, b, \\dots, z\\} $ be the alphabet of lowercase English letters.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 3 \\cdot 10^5 $  \n2. $ |O| = |I| = n $  \n3. All characters in $ O $ and $ I $ are from $ \\Sigma $.  \n\n**Objective**  \nThe players alternate turns, with Oleg moving first. On each turn, a player selects one letter from their multiset and places it in any remaining position of the $ n $-length string (initially all '?'). The letter is then removed from their multiset.  \n\n- Oleg aims to **minimize** the lexicographic value of the final string.  \n- Igor aims to **maximize** the lexicographic value of the final string.  \n\nBoth play optimally.  \n\nCompute the resulting string after $ n $ moves.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF794C","tags":["games","greedy","sortings"],"sample_group":[["tinkoff\nzscoder","fzfsirk"],["xxxxxx\nxxxxxx","xxxxxx"],["ioi\nimo","ioi"]],"created_at":"2026-03-03 11:00:39"}}