#P3742. umi的函数

    ID: 2701 远端评测题 800ms 128MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟字符串贪心Special Judge构造

umi的函数

Description

{{This function takes two strings s1,s2s1, s2. These strings consist only of lowercase letters and have the same length. The output of this function is another string gg whose length is the same as s1s1 and s2s2. The ii-th character of gg equals the minimum of the ii-th character of s1s1 and s2s2; simply put, gi=min(s1i,s2i)g_i=min(s1_i,s2_i).

For example: f(ab,ba)=aaf(\verb!ab!,\verb!ba!)= \verb!aa!, f(nzwzl,zizez)=niwelf(\verb!nzwzl!,\verb!zizez!)=\verb!niwel!.

She now has two strings x,yx, y of the same length, consisting only of lowercase letters. Find any string zz such that f(x,z)=yf(x,z)=y. If no such string exists, please output -1.}}

Input Format

{{The first line contains the length nn of the two strings. The second line contains the string xx. The third line contains the string yy.}}

Output Format

{{Output one string in the first line, representing a valid string you found. If none exists, output -1.}}

2
ab
aa
ba
5
nzwzl
niwel
xiyez

2
ab
ba

-1

Hint

{{Constraints: For 100% of the testdata, 1n1001 \le n \le 100.}}

Translated by ChatGPT 5