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 ...
随机推荐
- Apache Kylin的核心概念
不多说,直接上干货! 1.表(table):This is definition of hive tables as source of cubes,在build cube 之前,必须同步在 kyli ...
- P2955 [USACO09OCT]奇数偶数Even? Odd?
题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive int ...
- JDK使用最多的模式之一--观察者模式
公司接到新任务,需要做一个气象监测应用.该应用将实现三个界面:当前气象状态,气象统计以及气象预报.应用从WeatherObject对象中获取所需数据:温度,湿度,气压.当然,为了可扩展性,该应用同时也 ...
- centos安装字体
cd /usr/local/fonts/zh_CN/TrueType/ cp /root/simsunb.ttf /usr/share/fonts/zh_CN/TrueType/ mkfontscal ...
- git项目常用命令
git rm --cached 文件名 //移除不上传 git add . //添加所有文件 .gitignore //git忽略不想上传或者不需要上传的文件 REAMDE.md 文 ...
- IE11/Flash页游白屏怎么办!立刻开启IE大地址模式!缓解浏览器白屏问题
您是否经常发现IE白屏了,具体表现为点开新网页时无法显示,只能切换标签,用任务管理器一看,内存1.2G之多. 这是因为IE11可能有内存泄露问题,内存不断增长以至于无法申请新的内存,于是IE就完蛋了! ...
- COGS 1439. [NOIP2013]货车运输
★★☆ 输入文件:truck.in 输出文件:truck.out 简单对比时间限制:1 s 内存限制:128 MB [题目描述] [来源] CCF全国信息学奥林匹克联赛(NOIP201 ...
- GitHub简单命令行# 使用命令行传代码到GitHub
第一次提交代码到Github 第一步: 建立本地仓库cd到你的本地项目根目录下,执行git命令 cd到本地项目 git init 第二步: 将本地项目工作区的所有文件添加到暂存区 git add . ...
- lodash中文说明文档
lodash中文说明文档 https://www.css88.com/doc/lodash/
- 循环实现数组filter方法
// 循环实现数组 filter 方法 const selfFilter = function (fn, context){ // 如果调用的地方使用箭头函数,这里的this岂不是不对了,那该怎么解决 ...