#C9810. Circular String Rotation
Circular String Rotation
Circular String Rotation
Given two strings \( s \) and \( t \), determine if it is possible to transform \( s \) into \( t \) by performing a series of operations. In one operation, you may remove any one character from \( s \) and append it to the end of \( s \). It turns out that repeatedly performing this operation is equivalent to applying a cyclic rotation to \( s \). A key observation is that \( t \) is a rotation of \( s \) if and only if \( t \) is a substring of \( s+s \); i.e., \[ t \in (s+s) \quad \Longleftrightarrow \quad \text{YES} \] For example, if \( s = \text{'abc'} \), then \( t = \text{'cab'} \) can be obtained by two such operations.
inputFormat
The input consists of two lines. The first line contains the string \( s \) and the second line contains the string \( t \). Both strings consist only of lowercase English letters.
outputFormat
Output a single line containing YES
if it is possible to transform \( s \) into \( t \) using the allowed operations, and NO
otherwise.
abc
cab
YES