URAL 2040 Palindromes and Super Abilities 2
Palindromes and Super Abilities 2
Time Limit: 500MS Memory Limit: 102400KB 64bit IO Format: %I64d & %I64u
Description
Input
Output
Notes
Source
#include <bits/stdc++.h>
using namespace std;
const int maxn = ;
struct PalindromicTree{
struct node{
int son[],f,len;
void init(int len){
memset(son,,sizeof son);
this->len = len;
}
}e[maxn];
int tot,last,n;
char s[maxn];
int newnode(int len = ){
e[tot].init(len);
return tot++;
}
int getFail(int x){
while(s[n - e[x].len - ] != s[n]) x = e[x].f;
return x;
}
void init(){
last = tot = n = ;
newnode();
newnode(-);
e[].f = ;
s[n] = -;
}
bool extend(int c){
s[++n] = c;
int cur = getFail(last);
bool isExtend = e[cur].son[c] == ;
if(!e[cur].son[c]){
int newson = newnode(e[cur].len + );
e[newson].f = e[getFail(e[cur].f)].son[c];
e[cur].son[c] = newson;
}
last = e[cur].son[c];
return isExtend;
}
}pt;
char str[maxn];
int main(){
while(gets(str)){
pt.init();
for(int i = ; str[i]; ++i){
if(pt.extend(str[i] - 'a')) putchar('');
else putchar('');
}
putchar('\n');
}
return ;
}
URAL 2040 Palindromes and Super Abilities 2的更多相关文章
- Ural 2040. Palindromes and Super Abilities 2 回文自动机
2040. Palindromes and Super Abilities 2 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2040 ...
- URAL 2040 Palindromes and Super Abilities 2(回文树)
Palindromes and Super Abilities 2 Time Limit: 1MS Memory Limit: 102400KB 64bit IO Format: %I64d ...
- URAL 2040 Palindromes and Super Abilities 2 (回文自动机)
Palindromes and Super Abilities 2 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/E Descr ...
- Ural 1960 Palindromes and Super Abilities
Palindromes and Super Abilities Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged ...
- 回文树(回文自动机) - URAL 1960 Palindromes and Super Abilities
Palindromes and Super Abilities Problem's Link: http://acm.timus.ru/problem.aspx?space=1&num=19 ...
- 【URAL】1960. Palindromes and Super Abilities
http://acm.timus.ru/problem.aspx?space=1&num=1960 题意:给一个串s,要求输出所有的s[0]~s[i],i<|s|的回文串数目.(|s|& ...
- URAL1960 Palindromes and Super Abilities
After solving seven problems on Timus Online Judge with a word “palindrome” in the problem name, Mis ...
- 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 ...
- 回文树1960. Palindromes and Super Abilities
Bryce1010模板 http://acm.timus.ru/problem.aspx?space=1&num=1960 #include <bits/stdc++.h> usi ...
随机推荐
- 转-sql之left join、right join、inner join的区别
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录inner join(等值连接) 只 ...
- [在读]functional javascript
讲javascript函数化编程的一本书,逛淘宝正好看到有一家卖英文书的,顺手就买了,目前搁置.
- AJPFX总结private关键字
private关键字 什么是private关键字? 它是一个修饰符,代表私有的意思,它可以修饰成员变量和成员方法 private关键字的特点? ...
- 亲身经历,Java面试题整理
博主在2015年暑期参加过一些Java开发工程师实习的面试和笔试,在此将重点整理出来,以供大家学习. 资料1: 一.单继承 1.1Java类是否支持多重继承? 答:继承的基本原则是: 子类继承父类的所 ...
- android控件之webview和js与java交互
首先添加权限:<uses-permission android:name="android.permission.INTERNET"/> 布局文件: <Relat ...
- Android利用已有控件实现自定义控件
Android控件的基本介绍及使用自定义控件的意义 Android 本身提供了很多控件,自定义控件在android中被广泛运用,自定义控件给了我们很大的方便.比如说,一个视图为imag ...
- spring中junit 提示Failed to load ApplicationContext
错误提示: 1:java.lang.IllegalStateException: Failed to load ApplicationContext 2:Error creating bean wit ...
- Win10本地搭建Apache+PHP运行环境
微软全新操作系统Windows10在190个国家和地区正式同步上市,正版Windows7.Windows8.1用户均可在一年内免费升级.介绍一下在升级后的Windwos10系统上安装及配置Apache ...
- c++调用com口操作autocad
#include "stdafx.h" #include <atlcomcli.h> #import "D:\\C++test\\FirstCom\\Rele ...
- jquery--cookie应用
示例:发送手机验证码 防止页面刷新后,发送验证码按钮重置 注:橙色部分为后增加代码,为防止验证码等待期间用户退出或者切换到其他页面以至于很久之后回到当前页面倒计时还在的问题,加入时间对比,记录用户发送 ...