Theme Section
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
inline ll read(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /***********************************************************/ const int maxn = 1e6+;
char s[maxn];
int Next[maxn]; int main(){
int t;
t = read();
while(t--){
scanf("%s", s);
int len = strlen(s);
Next[] = -;
int k = -;
for(int i = ;i <= len;){
if(k == - || s[i] == s[k]){
Next[++i] = ++k;
}
else k = Next[k];
}
int ans = ;
for(int i = Next[len];i >= ;i--){
if(ans) break;
for(int j = len - i;j >= i;j--){
if(Next[j] >= i){
ans = i;
break;
}
}
}
printf("%d\n", ans);
}
return ;
}
Theme Section的更多相关文章
- Theme Section(KMP应用 HDU4763)
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- hdu 4763 Theme Section(KMP水题)
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- HDU 4763 Theme Section
题目: It's time for music! A lot of popular musicians are invited to join us in the music festival. Ea ...
- HDU 4763 Theme Section(KMP灵活应用)
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- hdu4763 Theme Section【next数组应用】
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- HDU 4763 Theme Section (2013长春网络赛1005,KMP)
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- (KMP灵活运用 利用Next数组 )Theme Section -- hdu -- 4763
http://acm.hdu.edu.cn/showproblem.php?pid=4763 Theme Section Time Limit: 2000/1000 MS (Java/Others) ...
- hdu4763 Theme Section
地址:http://acm.hdu.edu.cn/showproblem.php?pid=4763 题目: Theme Section Time Limit: 2000/1000 MS (Java/O ...
- HDU4763 Theme Section —— KMP next数组
题目链接:https://vjudge.net/problem/HDU-4763 Theme Section Time Limit: 2000/1000 MS (Java/Others) Mem ...
- HDU4763 Theme Section 【KMP】
Theme Section Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
随机推荐
- M1卡破解(自从学校升级系统之后,还准备在研究下)【转】
本文转载自: M1卡说明及使用proxmark3破解方法 看了网上写的一些关于M1卡的文章,多数有些误导之嫌.首先谈谈M1卡的规格,M1卡的容量为1KB,好多网上写8KB,这里其实是有个误区,应该是8 ...
- bzoj5213: [Zjoi2018]迷宫
好题!话说省选的都开始构造了吗 由于有K的倍数的限制所以不妨取模,先建K个点表示0~K-1这些数,第i个点向[i*m,i*m+m]建边.不难发现这是合法的但不一定是最优的 考虑合并等价的点,首先从直观 ...
- LightOJ 1132 Summing up Powers:矩阵快速幂 + 二项式定理
题目链接:http://lightoj.com/volume_showproblem.php?problem=1132 题意: 给定n.k,求(1K + 2K + 3K + ... + NK) % 2 ...
- js 时间格式处理插件 moment
官网: http://momentjs.cn/docs/#/plugins/ 各种API官网上都有详细的例子,这里就不做一一说明. 重点讲两个常用的: 一.获取当前日期 moment().format ...
- Django 发送email配置详解及各种错误类型
跟随Django Book的内容发送邮件不成功,总结一下需要配置好settings.py文件,还要注意一些细节. 1.在settings文件最后添加以下内容,缺一不可! EMAIL_HOST= 'sm ...
- OGG 11g Checkpoint 详解
OGG Checkpoint 详解 定位中断的位置,下次启动从中断的位置开始恢复. 1.target 端配置: 2.一条记录对应一个replicat 一. Extract Check ...
- WPF 后台触发 Validate UI‘s Element
wpf中有validateRule类, 用于界面元素的验证, 如何后台去控制validateRule呢? 1. UI层要binding写好的ValidateRule,分为Binding和MultiBi ...
- VijosP1250:分组背包
背景 Wind设计了很多机器人.但是它们都认为自己是最强的,于是,一场比赛开始了~ 描述 机器人们都想知道谁是最勇敢的,于是它们比赛搬运一些物品. 它们到了一个仓库,里面有n个物品,每个物品都有一个价 ...
- 三 Flask+ MySQL 数据库操作
一: __init__.py作用: __init__.py 文件的作用是将文件夹变为一个Python模块,Python 中的每个模块的包中,都有__init__.py 文件.通常__init__.py ...
- warning: conflicting types for built-in function 'puts'
warning: conflicting types for built-in function 'puts' [编译器版本] arm-linux-gcc 3.4.1 [问题描述] 在做嵌入式底层开发 ...