Codeforces Round 396 (Div. 2)
A
Mahmoud and Longest Uncommon Subsequence
Codeforces
1000
原题
←B →
翻译中…

While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.

翻译中…

Given two strings $*a*$ and $*b*$, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other.

翻译中…

A subsequence of some string is a sequence of characters that appears in the same order in the string, The appearances don't have to be consecutive, for example, strings "ac", "bc", "abc" and "a" are subsequences of string "abc" while strings "abbc" and "acb" are not. The empty string is a subsequence of any string. Any string is a subsequence of itself.

翻译中…

Input

翻译中…

The first line contains string $*a*$, and the second line — string $*b*$. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than $10^{5}$ characters.

翻译中…

Output

翻译中…

If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of $*a*$ and $*b*$.

翻译中…

Note

翻译中…

In the first example: you can choose "defgh" from string $*b*$ as it is the longest subsequence of string $*b*$ that doesn't appear as a subsequence of string $*a*$.

翻译中…

样例

Input #1
abcd
defgh
Output #1
5
InputCopy OutputCopy
Input #2
a
a
Output #2
-1
InputCopy OutputCopy
题目信息
题号
766A
时间限制
2 s
内存限制
256 MB
标签
构造
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。