#P4112. Reverse the LCS: Minimal Excluded Substrings and Subsequences

    ID: 17360 Type: Default 1000ms 256MiB

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 of abcdef, but bde 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 of abcdef, but bdd is not.

Your task is to compute the following four values:

  1. A shortest substring of \(a\) that is NOT a substring of \(b\).
  2. A shortest substring of \(a\) that is NOT a subsequence of \(b\).
  3. A shortest subsequence of \(a\) that is NOT a substring of \(b\).
  4. 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>