QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#10573. Saraga

统计

saraga 这个词是 sarana olahraga 的缩写,这是一个印度尼西亚语词汇,意为体育设施。它是由 sarana 一词的前缀 saolahraga 一词的后缀 ga 组合而成的。有趣的是,它也可以由 sarana 的前缀 saolahraga 的后缀 raga 组合而成。

如果一个缩写可以通过至少两种不同的方式拆分为两个非空子串,且第一个子串是 $S$ 的前缀,第二个子串是 $T$ 的后缀,那么这个缩写被称为“有趣的”。

给定两个字符串 $S$ 和 $T$。你需要创建一个长度最小的 $S$ 和 $T$ 的有趣缩写,或者确定是否无法创建有趣的缩写。

输入格式

第一行包含一个字符串 $S$ ($1 \le |S| \le 200\,000$)。 第二行包含一个字符串 $T$ ($1 \le |T| \le 200\,000$)。 字符串 $S$ 和 $T$ 仅由小写英文字母组成。

输出格式

如果无法创建有趣的缩写,输出 $-1$。 否则,在单行中输出一个代表 $S$ 和 $T$ 的长度最小的有趣缩写。如果存在多个解,输出其中任意一个即可。

样例

输入 1

sarana
olahraga

输出 1

saga

说明 1

你可以将 saga 拆分为 saga,或者 saga。缩写 saraga 也是有趣的,但 saga 的长度更短。

输入 2

berhiber
wortelhijau

输出 2

berhijau

说明 2

缩写 berhijau 也是长度最小的有趣缩写,因此它是另一个有效的解。

输入 3

icpc
icpc

输出 3

icpc

输入 4

icpc
jakarta

输出 4

-1

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.