#C7361. Taco: Check Substring Insertion Possibility
Taco: Check Substring Insertion Possibility
Taco: Check Substring Insertion Possibility
You are given two strings, s
and t
. You are allowed to perform exactly one insertion operation on s
: insert any one character from t
into any position (possibly at the beginning or end) of s
. The task is to determine whether it is possible to make t
appear as a contiguous substring in the new string after the insertion.
Detailed Explanation:
For every possible insertion position in s
and every character c
in t
, you construct a new string by inserting c
at that position in s
. If t
becomes a substring of this new string, output YES
. Otherwise, output NO
.
Examples:
- For
s = "abxyca"
andt = "abc"
, the answer isYES
. - For
s = "abcd"
andt = "ef"
, the answer isNO
.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains the string
s
. - The second line contains the string
t
.
outputFormat
Output a single line to standard output (stdout) containing YES
if it is possible to insert exactly one character from t
into s
such that t
becomes a substring of the resulting string. Otherwise, output NO
.
abxyca
abc
YES