题目链接:4503:两个串
听说这样的通配符匹配问题常用FFT搞一搞?好吧蒟蒻并不会
这样如果s1和s2相等当且仅当f[x]=0
但是这道题有通配符,所以我们要把是通配符的位置s2[i]=0
这样有通配符的位置相应的函数值就会为0,表示可以匹配一切
但是这样没法做,于是将s2数组拧一拧,翻转过来,发现就是一个卷积之类的了,可以用FFT。
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=888888;
const double pi=3.141592653589793238462643383279502884197169399375105820974944;
struct cp{
double r,i;
cp(double _r=0,double _i=0):r(_r),i(_i){}
cp operator + (cp x){return cp(r+x.r,i+x.i);}
cp operator - (cp x){return cp(r-x.r,i-x.i);}
cp operator * (cp x){return cp(r*x.r-i*x.i,r*x.i+i*x.r);}
}A[maxn],B[maxn],C[maxn],D[maxn];
int dig[maxn],rev[maxn],N=0,L=0,a[maxn],b[maxn];
char s1[maxn],s2[maxn];
double ans[maxn];
int p[maxn],num=0;
void FFT(cp a[],int flag){
for (int i=0;i>=1) dig[len++]=t&1;
for (int j=0;j