CF794C.Naming Company

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 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.

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 = _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)

客户奥列格和分析师伊戈尔是好朋友。然而,他们有时会为一些小事争论。最近,他们共同创办了一家新公司,但一直难以确定公司的名称。

为了解决这个问题,他们决定玩一个游戏。公司名称将由 nn 个字母组成。奥列格和伊戈尔各自拥有一组 nn 个字母(同一字母可能出现多次,且两人的字母集合可能不同)。初始时,公司名称由 nn 个问号 ? 表示。奥列格和伊戈尔轮流进行游戏,奥列格先手。在每一轮中,当前玩家可从自己的字母集合中选择一个字母 cc,并用它替换任意一个问号;随后,该字母 cc 将从其集合中移除一个副本。当所有问号均被字母替换后,游戏结束。

例如,假设奥列格的字母集合为 {i,o,i}\{i, o, i\},而伊戈尔的字母集合为 {i,m,o}\{i, m, o\}。一种可能的游戏过程如下:

  • 初始时,公司名称为 ???。
  • 奥列格将第二个问号替换为 'i',公司名称变为 ?i?;此时奥列格剩余的字母集合为 {i,o}\{i, o\}。
  • 伊戈尔将第三个问号替换为 'o',公司名称变为 ?io;此时伊戈尔剩余的字母集合为 {i,m}\{i, m\}。
  • 最后,奥列格将第一个问号替换为 'o',公司名称变为 oio;此时奥列格剩余的字母集合为 {i}\{i\}。

最终,公司名称为 oio。

奥列格希望公司名称在字典序上尽可能小,而伊戈尔则希望公司名称在字典序上尽可能大。若双方均采取最优策略,最终的公司名称将是什么?

字符串 s=s1s2…sms = s_1 s_2 \dots s_m 被称为字典序小于字符串 t=t1t2…tmt = t_1 t_2 \dots t_m(其中 s≠ts \ne t),当且仅当存在最小下标 ii,使得 si≠tis_i \ne t_i,且 si<tis_i < t_i(即对所有 j<ij < i,均有 sj=tjs_j = t_j)。

输入格式

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.

输入的第一行包含一个长度为 nn(1 ≤ n ≤ 3⋅1051 ≤ n ≤ 3·10^5)的字符串 ss。该字符串的所有字符均为小写英文字母,表示 Oleg 初始拥有的字母集合。

输入的第二行包含一个长度为 nn 的字符串 tt。该字符串的所有字符均为小写英文字母,表示 Igor 初始拥有的字母集合。

输出格式

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

输出应为一个由 n 个小写英文字母组成的字符串,表示在奥列格和伊戈尔均采取最优策略时所确定的公司名称。

输入输出样例

  • 输入#1

    tinkoff
    zscoder

    输出#1

    fzfsirk
  • 输入#2

    xxxxxx
    xxxxxx

    输出#2

    xxxxxx
  • 输入#3

    ioi
    imo

    输出#3

    ioi

说明/提示

One way to play optimally in the first sample is as follows :

  • Initially, the company name is ???????.
  • Oleg replaces the first question mark with 'f'. The company name becomes f??????.
  • Igor replaces the second question mark with 'z'. The company name becomes fz?????.
  • Oleg replaces the third question mark with 'f'. The company name becomes fzf????.
  • Igor replaces the fourth question mark with 's'. The company name becomes fzfs???.
  • Oleg replaces the fifth question mark with 'i'. The company name becomes fzfsi??.
  • Igor replaces the sixth question mark with 'r'. The company name becomes fzfsir?.
  • Oleg replaces the seventh question mark with 'k'. The company name becomes fzfsirk.

For the second sample, no matter how they play, the company name will always be xxxxxx.

第一个样例中一种最优的玩法如下:

  • 最初,公司名称为 ???????。
  • Oleg 将第一个问号替换为 'f',公司名称变为 f??????。
  • Igor 将第二个问号替换为 'z',公司名称变为 fz?????。
  • Oleg 将第三个问号替换为 'f',公司名称变为 fzf????。
  • Igor 将第四个问号替换为 's',公司名称变为 fzfs???。
  • Oleg 将第五个问号替换为 'i',公司名称变为 fzfsi??。
  • Igor 将第六个问号替换为 'r',公司名称变为 fzfsir?。
  • Oleg 将第七个问号替换为 'k',公司名称变为 fzfsirk。

对于第二个样例,无论双方如何进行游戏,公司名称最终都必定是 xxxxxx。

输入解题思路,AI测评打分。不知道怎么写?

首页