Smallest chosen word

0

90 votes
Algorithms, Greedy Algorithms
Problem

You are given three strings \(s_1\), \(s_2\), and \(s_3\). Let \(x\) be any subsequence of \(s_2\) (\(x\) can be an empty string). The name is in the form of (\(s_1+x+s_3\)), here (\(+\)) means concatenation of strings. You are required to print the lexicographically-smallest string \(s\).

Note: The string contains only lowercase letters.

Input format

  • First line: Three numbers denoting the size of \(s_1\), \(s_2\), and \(s_3\) respectively
  • Second line: Three strings \(s_1\), \(s_2\), and \(s_3\)

Output format

Print a lexicographically-smallest string.

Constraints

\(|s1|,|s2|,|s3|\le10^5\)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Here x is "def "

Editor Image

?