#TP0000066. Hai chuỗi (Two strings)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Hai chuỗi (Two strings)
Two strings
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given two nonempty strings and consisting of lowercase English letters. You may remove at most one contiguous substring from . The removed substring may be empty (remove nothing) or may consist of all of .
The remaining string must be a subsequence of : it can be obtained by removing zero or more characters from without changing the order of the remaining characters. Remove as few characters from as possible and output any resulting string of maximum length. If no character can remain, output -.
Input
The first line contains .
The second line contains .
Output
Print any maximum-length remaining string, obtained by deleting one contiguous substring of , that is also a subsequence of . Print - if the result must be empty.
Subtasks
- Subtask 1 (20 points): ; ; every character of is a lowercase English letter.
- Subtask 2 (30 points): ; ; every character of is a lowercase English letter.
- Subtask 3 (50 points): ; ; every character of is a lowercase English letter.
Examples
Input
abca
accepted
Output
ac
Explanation
The string has eight characters. Removing the six-character suffix cepted (positions through ) leaves ac, which occurs at positions and of . Removing a shorter contiguous substring cannot leave three characters forming a subsequence of . Therefore the two-character result is optimal.