#K76902. Taco Transformation
Taco Transformation
Taco Transformation
Given two strings str1
and str2
, and an integer k
, you are to determine if it is possible to transform str1
into str2
using exactly k
operations.
In one operation, you can either delete the last character of the current string or append any character to the end of the current string.
Let \(L_1\) and \(L_2\) denote the lengths of str1
and str2
, respectively, and let \(c\) be the length of the longest common prefix of both strings. The minimum number of operations required to transform str1
into str2
is given by:
\(total = (L_1 - c) + (L_2 - c)\)
The transformation is possible if and only if total \le k
and the difference \(k - total\) is even (i.e., \((k - total) \mod 2 = 0\)).
inputFormat
The input is read from stdin
and consists of three lines:
- The first line contains the string
str1
. - The second line contains the string
str2
. - The third line contains the integer
k
.
outputFormat
Output a single line to stdout
:
Yes
if the transformation fromstr1
tostr2
in exactlyk
operations is possible.No
otherwise.
abc
def
6
Yes