PanH @ 2020-05-09 13:53:43
大概思路是做manacher时每一个符合条件的位置看一下前半部分是不是回文,判定方法是在前半部分的中点p判一下d[p]*2==d[i].这个思路有没有问题啊?
交上去之后WA了#1 #3 #8
#include<bits/stdc++.h>
using namespace std;
int len,d[2000005],ans;
char s[2000005];
inline void READ()
{
len=0;
s[0]='?',s[++len]='!';
char ch=getchar();
while(ch<'a'||ch>'z') ch=getchar();
while(ch>='a'&&ch<='z') s[++len]=ch,s[++len]='!',ch=getchar();
}
int main()
{
cin>>len;
READ();
// cout<<s<<endl;
int r=0,mid=0;
for(int i=1;i<=len;i++)
{
if(i<=r) d[i]=min(d[(mid<<1)-i],r-i);
while(s[i+d[i]]==s[i-d[i]]&&i+d[i]<=len&&i-d[i]) d[i]++;
d[i]--;
if(r<=i+d[i]) r=i+d[i],mid=i;
if(s[i]=='!'&&s[i-(d[i]>>1)]=='!')
{
int p=i-(d[i]>>1);
if((d[p]<<1)==d[i]) ans=max(ans,d[i]);
}
// cout<<d[i]<<' ';
}
// cout<<endl;
cout<<ans;
return 0;
}
by FZzzz @ 2020-05-09 15:10:26
@panhan 那不一定是左边中点吧,有可能是左边的中点右边的某个点
by FZzzz @ 2020-05-09 15:10:49
(纯口胡,不会马拉车(((
by PanH @ 2020-05-09 15:18:41
@FZzzz 好像有点道理,不过您都是红名大佬了就不要演了(
by FZzzz @ 2020-05-09 15:20:36
@panhan 我真的不会,我这几天把马拉车都忘干净了(
by PanH @ 2020-05-09 15:25:49
@FZzzz 要不是我看了提交记录,我差点信了(
by 初云悕 @ 2020-05-09 15:26:17
帮ph大佬附下截图
by PanH @ 2020-05-09 15:26:19
大佬装弱石锤了(
by FZzzz @ 2020-05-09 15:26:58
@panhan 咋了我用 PAM 做的(
by 初云悕 @ 2020-05-09 15:27:01
顺便围观神贴(误)的诞生!
by PanH @ 2020-05-09 15:27:55
@FZzzz 那就当我没说吧(