#P4112. Reverse the LCS: Minimal Excluded Substrings and Subsequences
Reverse the LCS: Minimal Excluded Substrings and Subsequences
Reverse the LCS: Minimal Excluded Substrings and Subsequences
After being tired of problems about longest common substrings and subsequences, you decide to reverse the challenge. Given two lowercase strings \(a\) and \(b\), recall that:
- A substring of a string is a contiguous segment. For example,
bcd
is a substring ofabcdef
, butbde
is not. - A subsequence of a string is a sequence that can be obtained by deleting some characters (possibly none) from the string while keeping the order. For example,
bde
is a subsequence ofabcdef
, butbdd
is not.
Your task is to compute the following four values:
- A shortest
substring
of \(a\) that is NOT a substring of \(b\). - A shortest
substring
of \(a\) that is NOT a subsequence of \(b\). - A shortest
subsequence
of \(a\) that is NOT a substring of \(b\). - A shortest
subsequence
of \(a\) that is NOT a subsequence of \(b\).
If for any case there is no valid answer, output a single dash "-" (without quotes) for that case.
inputFormat
The input consists of two lines. The first line contains the string \(a\), and the second line contains the string \(b\). Both strings consist of lowercase letters.
outputFormat
Output four lines. The first line is the answer for task 1, the second for task 2, the third for task 3, and the fourth for task 4.
sample
abc
abc
-
ac
</p>