QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#16458. Shortest Non-Common Substring

الإحصائيات

After getting tired of solving various longest common substring and subsequence problems, you decide to do the opposite.

A "substring" of a string refers to a contiguous segment of it; for example, bcd is a substring of abcdef, but bde is not.

A "subsequence" of a string refers to a segment that does not have to be contiguous; for example, bde is a subsequence of abcdef, but bdd is not.

Given two strings $A$ and $B$ consisting of lowercase letters, please calculate:

(1) The length of the shortest substring of $A$ that is not a substring of $B$. (2) The length of the shortest substring of $A$ that is not a subsequence of $B$. (3) The length of the shortest subsequence of $A$ that is not a substring of $B$. (4) The length of the shortest subsequence of $A$ that is not a subsequence of $B$.

Input

The input contains two lines, each containing a string of lowercase letters, representing $A$ and $B$ respectively.

Output

Output 4 lines, each containing an integer representing the length of the answer to the above 4 problems. If no such answer exists, output -1.

Examples

Input 1

aabbcc
abcabc

Output 1

2
4
2
4

Input 2

aabbcc
aabbcc

Output 2

-1
-1
-1
-1

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.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.