Palindromes and Super Abilities

Problem's Link: http://acm.timus.ru/problem.aspx?space=1&num=1960


Mean:

给你一个长度为n的字符串S,输出S的各个前缀中回文串的数量。

analyse:

回文树(回文自动机)的模板题。

由于回文自动机中的p是一个计数器,也相当于一个指针,记录的是当前插入字符C后回文树中有多少个节点。

那么我们只需要一路插,一路输出p-2就行。

p-2是因为一开始回文树中就有两个节点。这是两个根节点,分别是长度为偶数和奇数的回文串的根节点。

Time complexity: O(N)

Source code: 

;
;
; ;
            ;
            ;
            ;
           ) ;
           ) ;
            ;
           n ;
           S ; ;
     ) ;   ;
            ; ; );
     ;s);
           ;
}
/*

*/

代码2:

;
;
     ;
     )
     ;
           ;
            ; ;
     ; ;
     ; ;
; );
);
;
}

回文树(回文自动机) - URAL 1960 Palindromes and Super Abilities的更多相关文章

  1. Ural 1960 Palindromes and Super Abilities

    Palindromes and Super Abilities Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged ...

  2. Ural 2040. Palindromes and Super Abilities 2 回文自动机

    2040. Palindromes and Super Abilities 2 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2040 ...

  3. URAL 2040 Palindromes and Super Abilities 2(回文树)

    Palindromes and Super Abilities 2 Time Limit: 1MS   Memory Limit: 102400KB   64bit IO Format: %I64d ...

  4. URAL 2040 Palindromes and Super Abilities 2 (回文自动机)

    Palindromes and Super Abilities 2 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/E Descr ...

  5. 【URAL】1960. Palindromes and Super Abilities

    http://acm.timus.ru/problem.aspx?space=1&num=1960 题意:给一个串s,要求输出所有的s[0]~s[i],i<|s|的回文串数目.(|s|& ...

  6. 回文树1960. Palindromes and Super Abilities

    Bryce1010模板 http://acm.timus.ru/problem.aspx?space=1&num=1960 #include <bits/stdc++.h> usi ...

  7. URAL 2040 Palindromes and Super Abilities 2

    Palindromes and Super Abilities 2Time Limit: 500MS Memory Limit: 102400KB 64bit IO Format: %I64d &am ...

  8. [模板] 回文树/回文自动机 && BZOJ3676:[Apio2014]回文串

    回文树/回文自动机 放链接: 回文树或者回文自动机,及相关例题 - F.W.Nietzsche - 博客园 状态数的线性证明 并没有看懂上面的证明,所以自己脑补了一个... 引理: 每一个回文串都是字 ...

  9. 回文树(回文自动机PAM)小结

    回文树学习博客:lwfcgz    poursoul 边写边更新,大概会把回文树总结在一个博客里吧... 回文树的功能 假设我们有一个串S,S下标从0开始,则回文树能做到如下几点: 1.求串S前缀0~ ...

随机推荐

  1. ormlite操作表记录

    实体类的创建对应表中people表, @DatabaseTable(tableName="people") public class People { @DatabaseField ...

  2. Could not parse the file: d:\matlab7\toolbox\ccslink\ccslink\info.xml

    找到安装目录下的info.xml文件,用记事本打开. 我的安装目录是:D:\MATLAB7\toolbox\ccslink\ccslink 用记事本打开,显示如下内容: <productinfo ...

  3. PHP XML Parser函数

    PHP XML Parser 函数 PHP XML Parser 简介 XML 函数允许您解析 XML 文档,但无法对其进行验证. XML 是一种用于标准结构化文档交换的数据格式.您可以在我们的 XM ...

  4. git:could not open a connection to your authentication agent

    git:could not open a connection to your authentication agent   错误: vagrant@homestead:~/Code/sample$ ...

  5. Python list删除元素

    pop()方法 pop(n) 从list删除元素Paul同学刚来几天又要转走了,那么我们怎么把Paul 从现有的list中删除呢?如果Paul同学排在最后一个,我们可以用list的pop()方法删除: ...

  6. webpack 引入jquery和第三方jquery插件

    1.引入jquery jQuery 直接在 html 中引入,然后在 webpack 中把它配置为全局即可. index.html: <!DOCTYPE html> <html> ...

  7. nginx配置用户认证

    location ~ .*admin\.php$ {             auth_basic "weifenglinux auth";             auth_ba ...

  8. CentOS 6.3下Samba服务器的安装与配置(转)

    一.简介 Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,而SMB是Server Message Block的缩写,即为服务器消息块 ,SMB主要是作为Microsoft的 ...

  9. Linux命令-文件搜索命令:whereis

    主要用途:查找linu命令,而不是磁盘上的普通文件,并且能看到命令的目录和帮助文件. whereis useradd 查找命令useradd的所在位置,同时还查出来它的帮助文件所在位置 whereis ...

  10. EMQ ---客户端上线自动订阅主题

    通过修改配置文件即可实现. emq v2.3.11,软件架构做了调整,把功能集成在了emq_modules模块,/data/loaded_plugins默认会加载emq_modules. 我们只需要改 ...