输入给出了最小循环节长度,暗示next数组. 然后自己按照自己的kmp板子逆着来一遍就好. ; int n, a, Next[maxn]; char str[maxn]; ]; int main() { read(n); rep(i, , n) { read(a); Next[i] = i - a; } str[] = 'a'; , j = ; i <= n; j = Next[i++]) { ) { str[i] = str[j + ]; } else { init(mark, ); do {…