#P4112. [HEOI2015] 最短不公共子串
[HEOI2015] 最短不公共子串
Description
Tired of problems about the longest common substrings and subsequences, you decide to go the other way.
Definitions:
- A "substring" of a string is a contiguous segment of it. For example,
bcdis a substring ofabcdef, butbdeis not. - A "subsequence" of a string is a segment that does not need to be contiguous. For example,
bdeis a subsequence ofabcdef, butbddis not.
Given two lowercase strings , please compute:
- A shortest substring of that is not a substring of .
- A shortest substring of that is not a subsequence of .
- A shortest subsequence of that is not a substring of .
- A shortest subsequence of that is not a subsequence of .
Input Format
There are two lines, each containing a string of lowercase letters, representing and respectively.
Output Format
Output lines, each containing one integer, representing the lengths of the answers to the above questions in order. If there is no valid answer, output .
aabbcc
abcabc
2
4
2
4
aabbcc
aabbcc
-1
-1
2
-1
Hint
Constraints:
- For of the testdata, the lengths of and do not exceed .
- For of the testdata, the lengths of and do not exceed .
- For of the testdata, the lengths of and do not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号