#C3029. Cyclic Permutations
Cyclic Permutations
Cyclic Permutations
Given two strings a and b, determine whether b is a cyclic permutation (or rotation) of a. In other words, b is a cyclic permutation of a if there exists an integer \( k \) (with \( 0 \leq k < n \), where \( n \) is the length of the strings) such that
\( b = a[k:] + a[:k] \)
Note that if the lengths of a and b are not equal, then b cannot be a cyclic permutation of a.
inputFormat
The input is provided via standard input and consists of a single line containing two space-separated strings.
outputFormat
Output to standard output a single line containing YES
if the two strings are cyclic permutations of each other; otherwise, output NO
.
abc abc
YES
</p>