CF1144E.Median String

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than tt.

Let's consider list of all strings consisting of exactly kk lowercase Latin letters, lexicographically not less than ss and not greater than tt (including ss and tt) in lexicographical order. For example, for k=2k=2, s=s="az" and t=t="bf" the list will be ["az", "ba", "bb", "bc", "bd", "be", "bf"].

Your task is to print the median (the middle element) of this list. For the example above this will be "bc".

It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.

给你两个字符串 ss 和 tt,它们均由恰好 kk 个小写拉丁字母组成,且 ss 在字典序上严格小于 tt。

考虑所有由恰好 kk 个小写拉丁字母组成的字符串构成的列表,这些字符串在字典序上不小于 ss 且不大于 tt(包含 ss 和 tt),并按字典序升序排列。例如,当 k=2k=2、s=s="az"、t=t="bf" 时,该列表为 ["az", "ba", "bb", "bc", "bd", "be", "bf"]。

你的任务是输出该列表的中位数(即中间那个元素)。对上述例子而言,答案为 "bc"。

题目保证:字典序不小于 ss 且不大于 tt 的字符串个数为奇数。

输入格式

The first line of the input contains one integer kk (1≤k≤2⋅1051 \le k \le 2 \cdot 10^5) — the length of strings.

The second line of the input contains one string ss consisting of exactly kk lowercase Latin letters.

The third line of the input contains one string tt consisting of exactly kk lowercase Latin letters.

It is guaranteed that ss is lexicographically less than tt.

It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.

输入的第一行包含一个整数 kk(1≤k≤2⋅1051 \le k \le 2 \cdot 10^5)—— 字符串的长度。

输入的第二行包含一个字符串 ss,该字符串恰好由 kk 个小写拉丁字母组成。

输入的第三行包含一个字符串 tt,该字符串恰好由 kk 个小写拉丁字母组成。

保证 ss 的字典序严格小于 tt。

保证字典序不小于 ss 且不大于 tt 的字符串个数为奇数。

输出格式

Print one string consisting exactly of kk lowercase Latin letters — the median (the middle element) of list of strings of length kk lexicographically not less than ss and not greater than tt.

输出一个恰好由 kk 个小写拉丁字母组成的字符串——即所有长度为 kk、字典序不小于 ss 且不大于 tt 的字符串所构成的列表中的中位数(中间元素)。

输入输出样例

  • 输入#1

    2
    az
    bf

    输出#1

    bc
  • 输入#2

    5
    afogk
    asdji

    输出#2

    alvuw
  • 输入#3

    6
    nijfvj
    tvqhwp

    输出#3

    qoztvz

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

首页