#P6863. Isomorphic Strings
Isomorphic Strings
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).
6
1
a
2
aa
3
aab
4
abba
6
abcbcc
8
aaaaaaaa
No
Yes
No
Yes
No
Yes