[Solution] Lex String Codeforces Solution | Codeforces Problem Solution 2022
Kuznecov likes art, poetry, and music. And strings consisting of lowercase English letters.
Recently, Kuznecov has found two strings, and , of lengths and respectively. They consist of lowercase English letters and no character is contained in both strings.
Let another string be initially empty. Kuznecov can do the following two types of operations:
- Choose any character from the string , remove it from , and add it to the end of .
- Choose any character from the string , remove it from , and add it to the end of .
But, he can not do more than operations of the same type in a row. He must perform operations until either or becomes empty. What is the lexicographically smallest possible value of after he finishes?
A string is lexicographically smaller than a string if and only if one of the following holds:
- is a prefix of , but ;
- in the first position where and differ, the string has a letter that appears earlier in the alphabet than the corresponding letter in .
The first line of each test case contains three integers , , and () — parameters from the statement.
The second line of each test case contains the string of length .
The third line of each test case contains the string of length .
The strings contain only lowercase English letters. It is guaranteed that no symbol appears in and simultaneously.
In each test case, output a single string — the answer to the problem.
No comments:
Post a Comment