Isomorphic Strings

TimeLimit:8000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
It is preferrable to read the pdf statment.

Two strings are called cyclical isomorphic if one can rotate one string to get another one. 'Rotate' here means ''to take some consecutive chars (maybe none) from the beginning of a string and put them back at the end of the string in the same order''. For example, string ''abcde'' can be rotated to string ''deabc''.

Now that you know what cyclical isomorphic is, Cuber QQ wants to give you a little test.

Here is a string $s$ of length $n$. Please check if $s$ is a concatenation of $k$ strings, $s_1,s_2,\cdots,s_k$ ($k>1$), where,

  • $k$ is a divisor of $n$;

  • $s_1,s_2,\ldots,s_k$ are of equal length: $\frac{n}{k}$;

  • There exists a string $t$, which is cyclical isomorphic with $s_i$ for all $1\le i\le k$.


Print ''Yes'' if the check is positive, or ''No'' otherwise.
Input
The first line contains an integer $T$ ($1\le T\le 1000$), denoting the number of test cases. $T$ cases follow.

  • The first line of each test case contains an integer $n$ ($1\le n \le 5 \cdot 10^6$).

  • The second line contains a string $s$ of length $n$ consists of lowercase letters only.


It is guaranteed that the sum of $n$ does not exceed $2\cdot 10^7$.
Output
For each test case, output one line containing ''Yes'' or ''No'' (without quotes).
SampleInput
6
1
a
2
aa
3
aab
4
abba
6
abcbcc
8
aaaaaaaa
SampleOutput
No
Yes
No
Yes
No
Yes
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: