请问这份代码哪里有问题?
#include<bits/stdc++.h>
using namespace std;
const int MAXN=50020;
int n,m,tot;
long long ans;
char c[MAXN],d[MAXN];
struct PAM
{
int cnt,last;
int sum[MAXN];
int son[MAXN][28];
int len[MAXN];
int fail[MAXN];
int t[MAXN];
int new_node(int u)
{
len[++cnt]=u;
return cnt;
}
int get_fail(int pre,int now,char *s)
{
while (s[now-len[pre]-1]!=s[now])
pre=fail[pre];
return pre;
}
void init()
{
cnt=1,last=0;
len[0]=0,len[1]=-1;
fail[0]=1;
fail[1]=1;
}
void insert(char ch,int k,char *s)
{
int cur=get_fail(last,k,s);
if (!son[cur][ch-'a'])
{
int now=new_node(len[cur]+2);
fail[now]=son[get_fail(fail[cur],k,s)][ch-'a'];
son[cur][ch-'a']=now;
}
last=son[cur][ch-'a'];
t[last]++;
}
}p1,p2;
void dfs(int l,int r)
{
if ((l+r)>2) ans+=1ll*p1.t[l]*p2.t[r];
for (int i=0;i<26;i++)
if (p1.son[l][i]&&p2.son[r][i]) dfs(p1.son[l][i],p2.son[r][i]);
}
int main()
{
scanf("%s%s",c+1,d+1);
n=strlen(c+1);m=strlen(d+1);
p1.init(),p2.init();
for (int i=1;i<=n;i++) p1.insert(c[i],i,c);
for (int i=1;i<=m;i++) p2.insert(d[i],i,d);
for (int i=p1.cnt;i;i--) p1.t[p1.fail[i]]+=p1.t[i];
for (int i=p2.cnt;i;i--) p2.t[p2.fail[i]]+=p2.t[i];
dfs(1,1);dfs(0,0);
printf("%lld\n",ans);
return 0;
}