CF762C.Two strings

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of the characters from b and make it empty.

Subsequence of string s is any such string that can be obtained by erasing zero or more characters (not necessarily consecutive) from string s.

给你两个字符串 aa 和 bb。你需要从字符串 bb 中最少删除多少个连续的(彼此相邻的)字符,使得剩余的 bb 成为字符串 aa 的一个子序列。有可能你完全不需要删除任何字符,也有可能你需要删去 bb 中的所有字符,使其变为空串。

字符串 ss 的子序列是指:通过从 ss 中删除零个或多个字符(不一定是连续的) 所能得到的任意字符串。

输入格式

The first line contains string a, and the second line — string b. Both of these strings are nonempty and consist of lowercase letters of English alphabet. The length of each string is no bigger than 105 characters.

第一行包含字符串 aa,第二行包含字符串 bb。这两个字符串均非空,且仅由小写英文字母组成。每个字符串的长度均不超过 10510^5 个字符。

输出格式

On the first line output a subsequence of string a, obtained from b by erasing the minimum number of consecutive characters.

If the answer consists of zero characters, output «-» (a minus sign).

在第一行输出字符串 a 的一个子序列,该子序列由字符串 b 通过删除最少数量的连续字符得到。

如果答案为空(即包含零个字符),则输出 «-»(一个减号)。

输入输出样例

  • 输入#1

    hi
    bob

    输出#1

    -
  • 输入#2

    abca
    accepted

    输出#2

    ac
  • 输入#3

    abacaba
    abcdcba

    输出#3

    abcba

说明/提示

In the first example strings a and b don't share any symbols, so the longest string that you can get is empty.

In the second example ac is a subsequence of a, and at the same time you can obtain it by erasing consecutive symbols cepted from string b.

在第一个例子中,字符串 aa 和 bb 不包含任何共同的字符,因此你能得到的最长字符串为空串。

在第二个例子中,acac 是字符串 aa 的一个子序列,同时你也可以通过对字符串 bb 删除连续的子串 ceptedcepted 得到它。

输入解题思路,AI测评打分。不知道怎么写?

首页