显示代码纯文本
#include <cstdio>
#include <bitset>
//#include <iostream>
#include <cstring>
const int MAXN=1E5+10;
std::bitset<MAXN> pos[26];
std::bitset<MAXN> ans;
int last[MAXN],sum;
char s[MAXN],t[MAXN];
int main() {
freopen("guess.in","r",stdin);
freopen("guess.out","w",stdout);
scanf("%s%s",s,t);
int len1=strlen(s);
int len2=strlen(t);
for(int i=0;i<len1;++i) {
ans[i]=pos[s[i]-'a'][i]=1;
}for(int i=0;i<len2;++i) {
//std::cout<<i<<" "<<t[i]<<" "<<ans<<std::endl;
if(t[i]=='?')continue;
int now=t[i]-'a';
pos[now]>>=i-last[now];
//std::cout<<" "<<pos[now]<<std::endl;
last[now]=i;
ans&=pos[now];
}//std::cout<<ans<<std::endl;
for(int i=0;i<len1-len2+1;++i) {
sum+=ans[i];
}
printf("%d\n",sum);
for(int i=0;i<len1-len2+1;++i) {
if(ans[i])printf("%d\n",i);
}fclose(stdin);fclose(stdout);
return 0;
}