#P3785. Text Correction

    ID: 17035 Type: Default 1000ms 256MiB

Text Correction

Text Correction

In this problem, you are given two strings, S and T. It is known that T was obtained by splitting an unknown string into three contiguous non-empty segments and then reassembling them in a fixed order to form S. Specifically, if we denote the three segments as A, B, and C (in the order they appear in T), the reassembly was done as follows:

$$S = C + A + B$$

Your task is to determine whether it is possible to recover S from T by splitting T into three non-empty parts A, B, and C such that when they are concatenated in the order C, A, B (from left to right) the result is exactly S. If such a split exists, output Yes and one valid segmentation (i.e. the values of A, B, and C in that order as they appear in T). Otherwise, output No.

Note: The segments must be contiguous parts of T and each segment must be non-empty.

inputFormat

The input consists of two lines:

  • The first line contains the string S (the original text).
  • The second line contains the string T (the scrambled text).

Both strings consist of printable characters and their lengths are between 1 and 105.

outputFormat

If it is possible to obtain S from T by splitting T into three non-empty segments A, B, and C such that S = C + A + B, then output Yes on the first line, and on the second line output the segments A, B, and C (separated by a space). Otherwise, output No.

sample

cab
abc
Yes

a b c

</p>