manacher 8pts 求条(悬两关)

P3805 【模板】manacher

@[endswitch](/user/773915) $p_i$ 中间那里应该要判断边界吧
by _JF_ @ 2024-02-05 21:12:47


@[_JF_](/user/361141) 您可以具体说一说吗
by endswitch @ 2024-02-05 21:13:36


@[endswitch](/user/773915) ```cpp while(a[i-p[i]]==a[i+p[i]]) p[i]++; ``` 应该要判断是否越过 $1$ 和 $n$吧
by _JF_ @ 2024-02-05 21:15:46


@[_JF_](/user/361141) 理论上应该不需要吧(我的边界赋初值了)
by endswitch @ 2024-02-05 21:18:44


@[endswitch](/user/773915) ```cpp #include <bits/stdc++.h> using namespace std; const int N=2.2e7+5; int j,l,mid,ans,p[N]; char a[N],s[N]; signed main() { ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); cin>>(s+1); l=strlen(s+1); for(int i=1;i<=l;i++) a[(i<<1)-1]=s[i],a[i<<1]='*'; l=strlen(a+1),a[0]='/'; for(int i=1;i<=l;i++) { if(i<=j) p[i]=min(p[(mid<<1)-i],j-i+1); while(a[i-p[i]]==a[i+p[i]]) p[i]++; if(p[i]+i>j) j=p[i]+i-1,mid=i; } for(int i=1;i<=l;i++) ans=max(ans,p[i]-1); cout<<ans; return 0; } ``` 84
by 2011FYCCCTA @ 2024-02-05 21:20:16


@[2011FYCCCTA](/user/923403) 这个我是试过的了,, 而且我不改就是对的这份做法错误的点
by endswitch @ 2024-02-05 21:21:48


欸我好像标题写错了( 应该是 16 pts 才对(
by endswitch @ 2024-02-05 21:22:23


@[endswitch](/user/773915) 哦
by 2011FYCCCTA @ 2024-02-05 21:22:54


|