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. 设计模式之访问者模式(Visitor )

    访问者模式是一种将数据操作和数据结构分离的设计模式,可以说是面向数据密集型的一种设计方式,数据的结构相对稳定,有明显的分层和分类,而对数据对象的相关操作进行分组.分析等二次加工,这些操作都是由访问者来 ...

  2. Ubuntu 18 + Redis安装

    Ubuntu 18 + Redis安装 1.安装命令: opengis@gisserver20:~$ sudo apt-get install redis-server 2.查看tcp 连接 open ...

  3. ionic打包报错Execution failed for task ':processDebugResources'

    ionic 打包的时候报了这样一个错误:Execution failed for task ':processDebugResources' 分析: compile "com.android ...

  4. Android Studio 点击两次返回键,退出APP

    该功能的实现没有特别复杂,主要在onKeyDown()事件中实现,直接上代码,如下: //第一次点击事件发生的时间 private long mExitTime; /** * 点击两次返回退出app ...

  5. Apktool(1)——Apktool的安装

    Apktool是google提供的apk的编译工具,有了它就可以做很多事情.比如获取apk的源码,apk汉化,对手机rom包做一些美化. 首先来看看apktool的安装(配置): 以下内容主要翻译字A ...

  6. 【redis专题(2)】命令语法介绍之string

    REDIS有5大数据结构:string,link,sortedset,sets,hash. 这5个结构我将用5篇文章来记录各自是怎么用的,然后再用一篇文章来说一下各自的应用场景: 更多语法请参考: h ...

  7. IntelliJ IDEA 2017 永久注册方法

    https://blog.csdn.net/weixin_39913200/article/details/80859897 在安装的idea下面的bin目录下面有2个文件 : 一个是idea64.e ...

  8. bootstrap-select插件 多选框

    HeBeiTianQi.jsp页面 1 <!--bootstrap-select .css引用--> 2 <link rel="stylesheet" href= ...

  9. apache 80端口占用问题

    今天安装mongodb后发现apache无法启动 命令行 services.msc 打开服务 在服务里启动Apache2a服务,报错误码1 网上查有很多情况都报的1 可以通过命令行下  执行apach ...

  10. ccf题库中2015年12月2号消除类游戏

    题目如下: 问题描述 消除类游戏是深受大众欢迎的一种游戏,游戏在一个包含有n行m列的游戏棋盘上进行,棋盘的每一行每一列的方格上放着一个有颜色的棋子,当一行或一列上有连续三个或更多的相同颜色的棋子时,这 ...