Comments

Me too, and my fault is that I forgot to judge a sqecial situation, when a suffix of the string is also its prefix, you need to cut out the suffix to get a better answer.

Prove:That's because if you found $$$S[1,n-i+1]=S[i,n]$$$ ,it means you've already judged suffix starts from 2 to i-1, ans all of them are smaller then itself, now we judge if we cut the $$$i^{th}$$$ suffix, if we cut it, we will connect itself to it after cutting(we call it s1 ans the one that didn't been cut s2), and it can be proved that the first place that may be different is the $$${n+1}^{th}$$$ place of s2, and it is the initial string again,for s1, it is the suffix from (n mod (i-1)+1) we know that if s[x] means the suffix from x,$$$s[j(1\le j \le i)]\le s[1]$$$,so $$$s1\le s2$$$, we need to cut it.

I also write in bitset,I see that someone said it can be hacked,I just want to get a hack data so that I can improve my code,ses there[submission:117940279]