CF584C.Marina and Vasya

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.

More formally, you are given two strings _s_1, _s_2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and b are different. Then your task will be to find any string _s_3 of length n, such that f(_s_1, _s_3) = f(_s_2, _s_3) = t. If there is no such string, print  - 1.

玛琳娜喜欢长度相同的字符串,而瓦西娅则喜欢存在第三个字符串,该字符串与前两个字符串恰好在 t 个字符上不同。请帮助瓦西娅找出至少一个这样的字符串。

更形式化地,给定两个长度为 n 的字符串 _s_₁、_s_₂ 以及一个整数 t。记 f(a, b) 为字符串 a 与 b 在不同位置上的字符个数。你的任务是找出任意一个长度为 n 的字符串 _s_₃,使得 f(_s_₁, _s_₃) = f(_s_₂, _s_₃) = t。若不存在这样的字符串,则输出 -1。

输入格式

The first line contains two integers n and t (1 ≤ n ≤ 105, 0 ≤ t ≤ n).

The second line contains string _s_1 of length n, consisting of lowercase English letters.

The third line contain string _s_2 of length n, consisting of lowercase English letters.

第一行包含两个整数 nn 和 tt(1 ≤ n ≤ 1051 \leq n \leq 10^5,0 ≤ t ≤ n0 \leq t \leq n)。

第二行包含一个长度为 nn 的字符串 s1s_1,由小写英文字母组成。

第三行包含一个长度为 nn 的字符串 s2s_2,由小写英文字母组成。

输出格式

Print a string of length n, differing from string _s_1 and from _s_2 in exactly t characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1.

输出一个长度为 nn 的字符串,该字符串与字符串 s1s_1 和 s2s_2 均恰好在 tt 个位置上不同。你的字符串只能由小写英文字母组成。如果不存在这样的字符串,则输出 -1。

输入输出样例

  • 输入#1

    3 2
    abc
    xyc

    输出#1

    ayd
  • 输入#2

    1 0
    c
    b

    输出#2

    -1

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

首页