intmain(){ int now(0), n, m; scanf("%s\n%s", s + 1, p + 1); n = strlen(s + 1), m = strlen(p + 1); nxt[1] = 0; for (int x = 2; x <= m;) if (p[now + 1] == p[x]) nxt[x ++] = ++ now; elseif (now) now = nxt[now]; else nxt[x ++] = 0; for (int i = 1, j = 1; i <= n;) { if (s[i] == p[j]) ++ i, ++ j; elseif (j != 1) j = nxt[j - 1] + 1; else ++ i; if (j > m) printf("%d\n", i - m), j = nxt[j - 1] + 1; } for (inti(1); i <= m; ++ i) printf("%d ", nxt[i]); return0; }