[KMP fail树] 51nod1277 字符串中的最大值
来源:互联网 发布:黑手党 知乎 编辑:程序博客网 时间:2024/06/07 06:02
题意
对于一个字符串
题解
一个点所代表的前缀的出现次数=在
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=100005;typedef long long LL;int n,nxt[maxn],sz[maxn];LL ans;char s[maxn];int main(){ freopen("51nod1277.in","r",stdin); freopen("51nod1277.out","w",stdout); scanf("%s",s+1); n=strlen(s+1); for(int i=2,j=0;i<=n;i++){ while(j&&s[j+1]!=s[i]) j=nxt[j]; if(s[j+1]==s[i]) j++; nxt[i]=j; } for(int i=n;i>=1;i--){ sz[i]++; ans=max(ans,(LL)sz[i]*i); sz[nxt[i]]+=sz[i]; } printf("%lld\n",ans); return 0;}
阅读全文
1 0
- [KMP fail树] 51nod1277 字符串中的最大值
- 【KMP-fail树】51Nod1277[字符串中的最大值]题解
- 51nod1277 字符串中的最大值(KMP)
- KMP——51nod1277 字符串中的最大值
- 【51Nod1277】字符串中的最大值
- 51NOD1277 字符串中的最大值
- [KMP next树] 51Nod 1277 字符串中的最大值
- 【KMP next树】51nod 1277 字符串中的最大值
- 51nod 1277 字符串中的最大值【KMP算法】【next树】
- 51nod-1277 字符串中的最大值(KMP)
- kmp-51nod 1277 字符串中的最大值
- 51 nod 1277 字符串中的最大值(KMP)
- 51nod 1277 字符串中的最大值(KMP)
- 51NOD 1277 字符串中的最大值 【拓展KMP】
- 51nod 1277 字符串中的最大值(kmp)
- 1277 字符串中的最大值 (kmp)
- 【Kmp求字符串前缀在字符串出现的次数】51nod 1277 字符串中的最大值
- 51Nod 1277 字符串中的最大值 KMP next数组经典应用
- 2017 暑假艾教集训 day1
- Pktgen支持套接字
- OutputStream类中的三种write方法
- 多继承
- Web前端(待续)
- [KMP fail树] 51nod1277 字符串中的最大值
- Unity3D
- 剑指offer 14---调整数组顺序使奇数位于偶数前面
- 多路复用I/O--select
- 谈谈分词
- 完美洗牌算法
- 201403-3 命令行选项
- 每日MySQL之007:MySQL复制之Binary Log File Position Based Replication
- QT之QStringList