题目描述
Problem Description
After getting tired of solving problems about the longest common substrings and subsequences, you decide to take a different approach.
Here are some definitions:
- A "substring" of a string refers to a continuous segment of the string, for example,
bcdis a substring ofabcdef, butbdeis not. - A "subsequence" of a string refers to a segment that can be non-continuous, for example,
bdeis a subsequence ofabcdef, butbddis not.
Given two strings \(a\) and \(b\) consisting of lowercase letters, please calculate:
- The shortest substring of \(a\) that is not a substring of \(b\).
- The shortest substring of \(a\) that is not a subsequence of \(b\).
- The shortest subsequence of \(a\) that is not a substring of \(b\).
- The shortest subsequence of \(a\) that is not a subsequence of \(b\).
Input Format
There are two lines, each containing a string consisting of lowercase letters, representing \(a\) and \(b\) respectively.
Output Format
Output 4 lines, each containing an integer, representing the lengths of the answers to the above 4 questions in order. If there is no valid answer, output -1.
Sample Input and Output
Sample Input #1
aabbcc
abcabc
Sample Output #1
2
4
2
4
Sample Input #2
aabbcc
aabbcc
Sample Output #2
-1
-1
2
-1
Notes
Data Size and Constraints
- For 20% of the data, the lengths of \(a\) and \(b\) do not exceed 20.
- For 50% of the data, the lengths of \(a\) and \(b\) do not exceed 500.
- For 100% of the data, the lengths of \(a\) and \(b\) do not exceed 2000.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
aabbcc
abcabc
样例输出
2
4
2
4