#P11579. Cyclic Rotation Substring Search
Cyclic Rotation Substring Search
Cyclic Rotation Substring Search
Thuc loves exploring cyclic rotations of strings. A cyclic rotation of a string is obtained by repeatedly moving the first character to the end of the string. For example, the cyclic rotations of ABCDE
are: ABCDE
, BCDEA
, CDEAB
, DEABC
, and EABCD
.
Given a text string $T$ and a string $S$, determine whether $T$ contains any cyclic rotation of $S$ as a substring. Mathematically, if we denote a cyclic rotation of $S$ as $S_i$ for some rotation index i, you need to check if there exists an i such that $S_i$ is a substring of $T$.
inputFormat
The input consists of two lines:
- The first line contains the text string $T$.
- The second line contains the string $S$.
Both strings may contain uppercase and lowercase letters.
outputFormat
Output a single line: Yes
if $T$ contains any cyclic rotation of $S$ as a substring, and No
otherwise.
sample
ABCDE
CDEAB
Yes