Codeforces 204 E

题意:给\(n\)个串,求对于每一个串在至少\(k\)个串中出现的它的子串\(S_{l..r}\)有多少个。

思路:后缀自动机上\(dp\)。。。

我们首先构造出这\(n\)个串的后缀自动机,其中需要注意将某个串的构建完了后直接将\(lst\)指针赋为\(root\),那么就可以包含这些串的所有子串并且不会有问题。

然后我们就考虑如何来算出某一个子串在\(n\)个串中出现了多少次。

假设现在我们从\(S_i\)的开头走到第\(j\)位,走到了节点\(u\),那么

看从\(u\)开始,沿着\(link\)一直走到\(root\)的一堆节点\(v_1..v_k\),这些节点表示的最长后缀没有在\(S_i\)中出现过,那么它们现在就标记为在\(S_i\)中出现过了,然后这些节点代表了结尾为\(j\)的所有子串们(根据定义),所以没有漏掉任何一个子串。

下面就是要求每一个节点对\(S_i\)的贡献了。对于节点\(u\),它对任何一个串的贡献就是它的\(link\)的贡献加上如果它出现大于等于\(k\)次,那么就再加上这个节点表示的子串数量:\(len_u-len_{link_u}\)(这个非常重要)。

那么顺着\(S_i\)跑到的每个节点\(u\)统计下答案就可以辣

【Codeforces 204E】Little Elephant and Strings的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【24.34%】【codeforces 560D】Equivalent Strings

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 798B】Mike and strings

    [题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去 ...

  4. 【52.49%】【codeforces 556A】Case of the Zeros and Ones

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 750E】New Year and Old Subsequence

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 761C】Dasha and Password(动态规划做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 761C】Dasha and Password(贪心+枚举做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. 【读书笔记】iOS-开发者证书

    虽然使用通配符听起来很赞,但问题是使用这种App ID的应用无法使用苹果的Push Notification服务以及应用内支付服务. 如果你有钱的话,建议单独买一个设备用于开发,将来你可能会安装iOS ...

  2. 【转】解决configure: error: C++ compiler cannot create executables问题

    转自:http://www.coderbolg.com/content/83.html 啊……天啊,./configure时报错:configure: error: C++ compiler cann ...

  3. Android-滑动解锁高亮文字自定义TextView

    public class HightLightTextView extends TextView { // 存储view的宽度 private int mTextViewWidth = 0; // 画 ...

  4. recovery 差分升级包制作超时

    我们在对android系统升级的时候,可以减少升级包的大小,只升级差异部分,也就是差分包升级,相关的描述可以参考:http://blog.csdn.net/csdn66_2016/article/de ...

  5. 动态导入模块:__import__、importlib、动态导入的使用场景

    相关内容: __import__ importlib 动态导入的使用场景 首发时间:2018-02-23 16:06 __import__: 功能: 是一个函数,可以在需要的时候动态导入模块 使用: ...

  6. Linux主机定期打补丁修复漏洞

    1.如图扫描出来的漏洞 不看不知道,一看吓一跳  2.Linux主机如何扫描漏洞 参照:Linux操作系统下查找漏洞的几种必备兵器 3.linux操作系统怎么样打补丁?linux系统升级软件 使用yu ...

  7. Java ——基础语法

    package myhello; // 本类所在的包的路径 import af.util.AfMath; // 导入对应的类 import java.util.Random; // 导入随机数的类 p ...

  8. 洗礼灵魂,修炼python(31)--面向对象编程(1)—面向对象,对象,类的了解

    面向对象 1.什么是面向对象 (图片来自网络) 哈哈,当然不是图中的意思. 1).面向对象(Object Oriented,OO)是软件开发方法.利用各大搜索引擎得到的解释都太官方,完全看不懂啥意思对 ...

  9. Mongo学习---mongo入门1

    Docker安装以及设置mongo用户 docker pull mongo (拉取镜像 默认最新版本) docker images (查看镜像) docker run -p 27017:27017 - ...

  10. mysqld_safe启动服务器总结

    mysqld_safe是服务端工具,用于启动mysqld,并且是mysqld的守护进程,mysqld_safe加&在后台运行$BASEDIR/bin/mysqld_safe & 优点就 ...