#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[],s[];
int n,l,p[],ans,k=-,m=;
void manacher()
{
int pos=,id=,x=;
for(int i=;i<=n-;i++)
{
if(pos<=i) x=;
else x=min(p[*id-i],pos-i);
while(s[i+x]==s[i-x]) x++;
p[i]=x;
if(i+x>pos)
{
pos=i+x;
id=i;
}
}
}
int main()
{
while(cin>>a)
{
if(a[]=='E') return ;
ans=,n=;
l=strlen(a);
s[n++]='%';
for(int i=;i<l;i++)
{
s[n++]='#';
s[n++]=a[i];
}
s[n++]='#';
s[n]='@';
manacher();
for(int i=;i<=n;i++)
if(ans<p[i])
{
ans=p[i];
k=i;
}
if(s[k]=='#') printf("Case %d: %d\n",m++,ans/*);
else printf("Case %d: %d\n",m++,ans/*-);
} }

manecher的更多相关文章

  1. Palindrome [Manecher]

    Palindrome Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 12214 Accepted: 4583 Descript ...

  2. Ural2040:Palindromes and Super Abilities(离线&manecher算法)

    Dima adds letters s1, …, sn one by one to the end of a word. After each letter, he asks Misha to tel ...

  3. wannafly 挑战赛8 E 小G的项链(manecher)

    链接:https://www.nowcoder.com/acm/contest/57/E 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit ...

  4. 【字符串】manacher算法

    Definition 定义一个回文串为从字符串两侧向中心扫描时,左右指针指向得字符始终相同的字符串. 使用manacher算法可以在线性时间内求解出一个字符串的最长回文子串. Solution 考虑回 ...

  5. NOIP2017赛前考试注意事项总结

     考前: 考试前把读入优化和库以及对拍文件打好做好准备工作,另外注意放松心态,太紧张了肯定考不好··将自己的注意力集中起来  考场策略: 考试的基本策略是对每于道题先想个20分钟,如果想不出个靠谱的方 ...

  6. 【CQ18高一暑假前挑战赛2】标程

    [昨晚打校赛,5个小时打完很累了,所以搞忘出题了...对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大] [A:bush博弈] #include<bits/st ...

随机推荐

  1. Java中的String[] args

    在每个java程序中都有一个方法,public static void main(String[] args)方法,这个参数看了好久没看懂,但是细细看来,还是挺简单的,所有的方法的参数都是一个道理,而 ...

  2. SNMP学习之结构体snmp_secmod_def

    此结构体中定义了各个回调函数,在函数init_ksm(E:\code\net-snmp-5.4.2.1\snmplib)中进行了初始化. void init_ksm(void) { struct sn ...

  3. LeetCode OJ 98. Validate Binary Search Tree

    Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...

  4. ubuntu下 编译Caffe的Matlab接口

    一般情况下不愿意使用Caffe的Matlab接口,总觉得Linux版的Matlab很难配置,但是现在搞目标检测,得到的源码是使用的Caffe的Matlab接口,只能硬着头皮上了. (1)修改caffe ...

  5. JavaScript跨域总结与解决办法 什么是跨域

    什么是跨域 1.document.domain+iframe的设置 2.动态创建script 3.利用iframe和location.hash 4.window.name实现的跨域数据传输 5.使用H ...

  6. 关于PHP执行超时的问题

    PHP配置文件的参数max_execution_time表示脚本执行超时时间 max_execution_time=0表示不限制 max_execution_time=2表示执行两秒后终止,同时报错F ...

  7. zzuli 1907: 小火山的宝藏收益 邻接表+DFS

    Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 113  Solved: 24 SubmitStatusWeb Board Description    ...

  8. UVA 10277 Boastin' Red Socks

    #include <iostream> #include<cstdio> #include<cstring> using namespace std; unsign ...

  9. checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=

    在对php进行安装的过程中出现如下错误: 1.报错信息: 1 checking for known struct flock definition... configure: error: Don't ...

  10. 在win7/8/10鼠标右键添加按下SHIFT键时弹出的“在此处打开命令窗口”

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Drive\shell\cmd]@="@shell32.dll,-8506&q ...