#C7907. Cyclic Shift Strings
Cyclic Shift Strings
Cyclic Shift Strings
In this problem, you are given two binary strings s and t, both of length n. The task is to determine whether string t can be obtained by performing a number of cyclic shifts on string s. A single cyclic shift removes the first character of s and appends it to the end. Mathematically, if
( s = s_1 s_2 \ldots s_n ), then one cyclic shift produces ( s' = s_2 s_3 \ldots s_n s_1 ).
Your program should print Yes
if t is a cyclic shift of s, and No
otherwise.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains an integer n, the length of the binary strings.
- The second line contains the binary string s.
- The third line contains the binary string t.
It is guaranteed that the lengths of s and t are exactly n.
outputFormat
Print to standard output (stdout) a single line containing either Yes
if t can be obtained by any number of cyclic shifts on s, or No
otherwise.## sample
5
11001
00111
Yes