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 ...
随机推荐
- Mybatis-Configuration-详解
Configuration MyBatis的初始化会执行SqlSessionFactoryBuilder的中build()方法,build方法又会调用XMLConfigBuilder()的内部pars ...
- 不通过ecplise,只通过文件目录 创建最简单的JSP文件
手动创建最简单的JSP 文件 1.在Tomcat 6.0的安装目录的webapps目录下新建一个目录,起名叫myapp. 2.在myapp目录下新建一个目录WEB-INF,注意,目录名称是区分大小 ...
- [已读]web性能实践日志
书是在今年5月份出版,但是书中的内容是发表于11年到12年之间的,如果知道这一点,我一定不会买~ 列举一下大致内容: YSlow localStroage读取数据最佳策略 性能优化各种策略(图片精灵 ...
- scau 17967 大师姐唱K的固有结界 分类暴力 + RMQ
由于能放两次,那么分类, 1.连续使用,(这个直接O(n^2)暴力) 2.分开使用. 分开使用的话,首先暴力枚举,用T时间,能从第1个位置,唱到第几首歌,然后剩下的就是从pos + 1, n这个位置, ...
- js中关于this的理解
常见:在普通函数中的this,指向 全局 function thisObj(name){ this.name = name; console.log(this); } 但是在严格模式下的函数,this ...
- AJPFX总结Collection集合(下)
List集合特有方法 特有方法.凡是可以操作角标的方法都是该体系特有的方法. 增 add(index,element);在指定位置添加元素 addAll(index ...
- 高阶函数之filter 和 sorted
filter函数 接受一个函数和序列,把传入的函数依次作用于每个序列,然后根据返回值时True还是False保留或舍弃元素. def func(n): if n%2 == 0: return n m ...
- qt read excel
void exceladapter::readfile(QString filename, QString sheetname, int colNo){ QSqlDatabase db = QSqlD ...
- IF-MIB::ifTable = No Such Object available on this agent at this OID
在server端口执行如下命令 [root@localhost ~]# snmpwalk -v2c -c public 客户端ip ifIF-MIB::ifTable = No Such Object ...
- webapi之fiddler头设置
Host: localhost:16648Connection: keep-aliveContent-Length: 36Accept: application/json, text/javascri ...