QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#9079. 汉明距离

Statistics

在信息论中,两个等长字符串之间的汉明距离(Hamming distance)是指对应符号不同的位置个数。换句话说,它衡量的是将一个字符串变换为另一个字符串所需的最少替换次数,或者说是可能将一个字符串变换为另一个字符串的最少错误次数。 — 维基百科

假设有两个长度相同的字符串,且仅包含小写字母。请找出一个与原字符串长度相同的字典序最小的字符串,使得该目标字符串与每个原字符串之间的汉明距离相等。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。 每个测试用例包含两行字符串,表示两个原字符串,它们仅包含小写字母。字符串长度小于 $10^4$,且所有字符串的总长度小于 $10^6$。

输出格式

对于每个测试用例,输出 Case x: y,其中 $x$ 表示从 1 开始的用例编号,$y$ 表示目标字符串的结果。目标字符串应仅包含小写字母。

样例

输入格式 1

2
abc
acd
abandon
newyork

输出格式 1

Case 1: aaa
Case 2: aaaaark

说明

样例 2: $HM(\text{abandon}, \text{aaaaark}) = HM(\text{newyork}, \text{aaaaark}) = 5$ 且 aaaaark 是满足约束条件的字典序最小的字符串。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.