当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3535:A+B

题目描述

The Research Institute of Given Strings (RIGS) is a well-known place where people investigate anything about strings. Peter works in the department of string operations of RIGS. His department invents different ways to add, multiply, divide strings and even to take a logarithm of a string based on another one.

Now Peter is involved in the new project concerning orthogonal strings. Peter proposed that two strings P = P1P2Pn and Q = Q1Q2Qn of equal length n are called orthogonal, if PiQi for each i in the range 1..n. String S of length n is called orthogonal to set of strings V = ‹V1, V2, …, Vm› (each of length n too) if S is orthogonal to Vj for any j in range 1..m.

Peter’s task is to invent the operation of orthogonal sum of two given strings. The current Peter’s proposal allows to add only strings on a basis of some set, if they are orthogonal to this set. To do this, Peter selects an arbitrary set of strings V such that all strings in V have the same length n. Then Peter takes all strings of length n orthogonal to V over a fixed alphabet and sorts them, thus obtaining a sorted sequence of strings T. Let’s denote the length of sequence T as M, and enumerate the elements of this sequence as T0, T1, …, TM−1. Now Peter says that the orthogonal sum of two strings A = Ta and B = Tb is a string C = Tc where c = (a + b) mod M.

Your task is to find the orthogonal sum of two given strings A and B on the basis of a given set V over the alphabet of small English letters.

输入解释

The first line of the input file contains two integers: n — the length of each string (1 ≤ n100 000) and k — the cardinality of V (1 ≤ nk ≤ 100 000). The next k lines contains strings V1, V2, …, Vk.

The last two lines contain strings A and B of length n. All strings Vj, A and B consist of small letters of English alphabet. It is guaranteed that A and B are orthogonal to V.

输出解释

Output the orthogonal sum of strings A and B on the basis V.

输入样例
#12 2
ac
ad
bb
bb
#22 1
yy
zz
zz
输出样例
#1be
#2zx

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3535

最后修改于 2020-10-29T07:03:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536