#C579. Cyclic Rotation Check

    ID: 49477 Type: Default 1000ms 256MiB

Cyclic Rotation Check

Cyclic Rotation Check

You are given an integer \( n \) and two strings \( s \) and \( t \) of length \( n \). Your task is to determine whether \( t \) is a cyclic rotation of \( s \). In other words, if you concatenate \( s \) with itself to form \( s+s \), check if \( t \) is a substring of \( s+s \).

A cyclic rotation means that the characters of \( s \) are rotated by some positions. For example, if \( s = \texttt{abcde} \), a cyclic rotation could be \( \texttt{cdeab} \).

If \( t \) is a cyclic rotation of \( s \), output "YES"; otherwise, output "NO".

inputFormat

The input is provided via standard input (stdin) and consists of three lines:

  • The first line contains an integer \( n \), the length of the strings.
  • The second line contains the string \( s \).
  • The third line contains the string \( t \).

outputFormat

Output a single line to standard output (stdout) containing either "YES" if \( t \) is a cyclic rotation of \( s \), or "NO" otherwise.

## sample
5
abcde
cdeab
YES

</p>