求调
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int nex[maxn];
string a,b;
int n,m;
int main(){
cin >> a >> b;
n=a.size(),m=b.size();
int j = 0;
nex[0] = 0;
for(int i = 1; i < m; i++){
while(j!=0 && b[j+1] != b[i])
j = nex[j];
if(b[j+1] == b[i]){
j++;
}
nex[i]=j;
}
j=0;
for (int i = 1; i < n; i++) {
while (j && a[i] != b[j + 1])
j = nex[j];
if (a[i] == b[j + 1])
j++;
if (j == m){
cout << i-j << "\n";
j=nex[j];
}
}
for (int i=1;i<=m;i++){
cout << nex[i] << " ";
}
}