fangzichang @ 2022-05-15 11:22:19
P3435
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
string s;
long long a[N],ans,len;
int main(){
cin>>len>>s;
for(int i=1,j=0;i<len;i++)
{
while(j>0&&s[i]!=s[j]) j=a[j-1];
if(s[i]==s[j]) j++;
a[i]=j;
}
for(int i=1,j=1;i<len;i++){
j=i;
while(a[j]>0) j=a[j-1];
if(a[j]!=0) a[i]=j;
ans+=i-j;
}
printf("%lld",ans);
puts("");
return 0;
}
1,10,12,16,19,20TLE;
13,14,15WA
呜呜呜真的找不到问题在哪
by Rty123 @ 2022-05-15 11:29:30
加油,奥利给(我这能这么说了)
by Einstein_bili @ 2022-05-15 11:29:58
??