处理出,那么直接枚举前后缀长度check即可。复杂度
注意多组数据。

#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define N 400010
#define ull unsigned long long
#define base 233

ull h[N], p[N], ha;
char s[N];
int n;

int main() {
    p[0] = 1;
    for(int i = 1; i < 400000; ++i) p[i] = p[i - 1] * base;
    while(~scanf("%s", s + 1)) {
        n = strlen(s + 1);
        for(int i = 1; i <= n; ++i) h[i] = h[i - 1] * base + (ull)s[i];
        for(int i = 1; i <= n; ++i) {
            if(h[i] == h[n] - h[n - i] * p[i]) printf("%d ", i);
        }
        puts("");
    }
    return 0;
}